From 46239b7b6df238e158aedaf0b84fc637380b6418 Mon Sep 17 00:00:00 2001 From: jgharston Date: Mon, 31 Oct 2022 19:43:09 +0000 Subject: [PATCH] Initial notes on non-compliant functionality. --- agon_graphics.asm | 22 +++++++++++++++++++++- agon_sound.asm | 9 ++++++++- exec.asm | 2 +- init.asm | 4 +++- main.asm | 13 +++++++------ misc.asm | 28 +++++----------------------- patch.asm | 42 ++++++++++++++++++++++++++++++++---------- ram.asm | 3 +++ sorry.asm | 2 ++ 9 files changed, 82 insertions(+), 43 deletions(-) diff --git a/agon_graphics.asm b/agon_graphics.asm index d083f90..342563b 100644 --- a/agon_graphics.asm +++ b/agon_graphics.asm @@ -58,7 +58,7 @@ MODE: CALL EXPRI EXX VDU 16H VDU L - CALL CLRSCN + CALL CLRSCN ; VDU 22,L should itself do CLRSCN JP XEQ ; GET(x,y): Get the ASCII code of a character on screen @@ -135,6 +135,12 @@ $$: BIT.LIL 2, (IX+sysvar_vpd_pflags) ; COLOUR colour ; COLOUR mode,R,G,B ; +; This looks wrong +; COLOUR n must be identical to VDU 17,n +; COLOUR n,m must be identical to VDU 19,n,m,0,0,0 +; COLOUR n,r,g,b must be identical to VDU 19,n,16,r,g,b +; See https://mdfs.net/Software/BBCBasic/Porting/VDUSpecs +; COLOUR: CALL EXPRI ; The colour / mode EXX LD A, L @@ -193,6 +199,12 @@ COLOUR_1: CALL COMMA ; GCOL mode,colour ; GCOL mode,R,G,B ; +; This looks wrong +; GCOL n must be identical to VDU 18,0,n +; GCOL n,m must be identical to VDU 18,n,m +; GCOL n,r,g,b must be identical to VDU 19,n,16,r,g,b +; See https://mdfs.net/Software/BBCBasic/Porting/VDUSpecs +; GCOL: CALL EXPRI ; Parse MODE EXX LD A, L @@ -254,6 +266,9 @@ COLOUR_LOOKUP: DB 00h,00h,00h ; Black DB FFh,FFh,FFh ; White ; PLOT mode,x,y +; PLOT x,y must be identical to VDU 25,69,x;y; +; PLOT n,x,y must be identical to VDU 25,n,x;y; +; See https://mdfs.net/Software/BBCBasic/Porting/VDUSpecs ; PLOT: CALL EXPRI ; Parse mode EXX @@ -270,6 +285,8 @@ PLOT_1: VDU 19H ; VDU code for PLOT JP XEQ ; MOVE x,y +; MOVE x,y must be identical to VDU 25,4,x;y +; See https://mdfs.net/Software/BBCBasic/Porting/VDUSpecs ; MOVE: CALL EXPR_W2 ; Parse X and Y LD C, 04H ; Plot mode 04H (Move) @@ -277,6 +294,9 @@ MOVE: CALL EXPR_W2 ; Parse X and Y ; DRAW x1,y1 ; DRAW x1,y1,x2,y2 +; DRAW x,y must be identical to VDU 25,5,x;y; +; DRAW x1,y1 TO x2,y2 must be identical to VDU 4,x1;y1; 25,5,x2;y2; +; See https://mdfs.net/Software/BBCBasic/Porting/VDUSpecs ; DRAW: CALL EXPR_W2 ; Get X1 and Y1 CALL NXT ; Are there any more parameters? diff --git a/agon_sound.asm b/agon_sound.asm index bfcd207..02b157f 100644 --- a/agon_sound.asm +++ b/agon_sound.asm @@ -47,7 +47,14 @@ SOUND: CALL EXPR_W2 ; DE: Channel/Control, HL: Volume ; Store in VDU vars ; LD C, A ; Store Volume in C - LD A, L + + LD A, H ; Get channel high byte + CP 32 + JP NC, XEQ ; Standard channels are &0xxx to &1xxx + ; This check should be done by MOS, but + ; this code only passes ChannelLow to MOS + + LD A, L ; Get channel low byte to A LD (VDU_BUFFER+0), A ; Channel XOR A LD (VDU_BUFFER+1), A ; Waveform diff --git a/exec.asm b/exec.asm index 0b2b607..7bbb085 100644 --- a/exec.asm +++ b/exec.asm @@ -244,7 +244,7 @@ $$: LD A, R ; Use the R register to seed the random number generator ; XEQ0: CALL NEWLIN XEQ: LD (ERRLIN),IY ; Error pointer - CALL TRAP ; Check keyboard + CALL TRAP ; Check for Escape XEQ1: CALL NXT INC IY CP ':' ; Seperator diff --git a/init.asm b/init.asm index 6b5fba4..ee1e757 100644 --- a/init.asm +++ b/init.asm @@ -50,7 +50,7 @@ RST_20: DS 8 RST_28: DS 8 RST_30: DS 8 ; -; The NMI interrupt vector (not currently used by AGON) +; The IRQ interrupt vector (not currently used by AGON) ; RST_38: EI RETI @@ -74,3 +74,5 @@ $$: LD (HL), E RET +; The NMI vector at 0066h also not currently used by AGON + diff --git a/main.asm b/main.asm index e48a187..540ee6f 100644 --- a/main.asm +++ b/main.asm @@ -158,21 +158,21 @@ PURGE: LD (HL),A ; Clear scratchpad LD (LISTON),A LD HL,NOTICE LD (ERRTXT),HL - CALL OSINIT ; Call the machine specific OS initialisation routines + CALL OSINIT ; Call the machine-specific OS initialisation routines, NZ=filename passed LD (HIMEM),DE ; This returns HIMEM (ramtop) in DE - store in the HIMEM sysvar LD (PAGE_),HL ; And PAGE in HL (where BASIC program storage starts) - store in PAGE sysvar - CALL NEWIT ; From what I can determine, NEWIT always returns with Z flag set - JP NZ,CHAIN0 ; So this auto-run will never run + CALL NEWIT ; NEWIT always returns with Z flag preserved + JP NZ,CHAIN0 ; NZ set from OSINIT, auto-run passed filename CALL TELL ; Output the welcome message DB "BBC BASIC (Z80) Version 3.00\n\r" NOTICE: DB "(C) Copyright R.T.Russell 1987\n\r" DB "\n\r", 0 ; -WARM: DB F6H ; Opcode for OR? Maybe to CCF (the following SCF will be the operand) +WARM: DB F6H ; Opcode for OR, to do CLC by skipping SCF ; ; This is the main entry point for BASIC ; -CLOOP: SCF ; See above - not sure why this is here! +CLOOP: SCF ; SCF to indicate COLD entry LD SP,(HIMEM) CALL PROMPT ; Prompt user LD HL,LISTON ; Pointer to the LISTO/OPT sysvar @@ -600,7 +600,7 @@ WARMNC: JP NC,WARM ; If exceeded the terminating line number then jump ; ; Check if "UNLISTABLE": ; - LD A,D ; TODO: What is "UNLISTABLE?" + LD A,D ; Line number = 0, don't list the line OR E JP Z,CLOOP ; @@ -1021,6 +1021,7 @@ SETOP2: INC HL ; Skip the 3 byte end of program marker (&00, ; ;NEWIT - NEW PROGRAM THEN CLEAR ; Destroys: H,L +; MUST preserve Z/NZ for autorun ; ;CLEAR - CLEAR ALL DYNAMIC VARIABLES INCLUDING ; FUNCTION AND PROCEDURE POINTERS. diff --git a/misc.asm b/misc.asm index 408b32c..7de69ba 100644 --- a/misc.asm +++ b/misc.asm @@ -2,12 +2,11 @@ ; Title: BBC Basic for AGON - Miscellaneous helper functions ; Author: Dean Belfield ; Created: 03/05/2022 -; Last Updated: 13/10/2022 +; Last Updated: 28/09/2022 ; ; Modinfo: ; 26/07/2022: Added NULLTOCR and CRTONULL -; 28/09/2022: Added CSTR_FNAME, BUF_DETOKEN, BUF_PBCDL -; 13/10/2022: Added CSTR_LINE +; 28/09/2022: Added CSTR_FNAME, BUF_DETOKEN, BUF_PBCDL INCLUDE "equs.inc" INCLUDE "macros.inc" @@ -20,8 +19,7 @@ XDEF SWITCH_A XDEF NULLTOCR XDEF CRTONULL - XDEF CSTR_FNAME - XDEF CSTR_LINE + XDEF CSTR_FNAME XDEF BUF_DETOKEN XDEF BUF_PBCDL @@ -162,23 +160,7 @@ CSTR_FNAME: LD A, (HL) ; Get source $$: XOR A ; Zero terminate the target string LD (DE), A INC DE ; And point to next free address - RET - -; Copy a CR terminated line to DE and zero terminate it -; HL: Source -; DE: Destination (ACCS) -; -CSTR_LINE: LD A, (HL) ; Get source - CP CR ; Is it CR - JR Z, $F - LD (DE), A ; No, so store - INC HL ; Increment - INC DE - JR CSTR_LINE ; And loop -$$: XOR A ; Zero terminate the target string - LD (DE), A - INC DE ; And point to next free address - RET + RET ; Detokenise a character into a buffer ; A: Character to detokenise @@ -228,7 +210,7 @@ $$: LD A, B ; If on first transition, skip this CP 5 ; TODO: Need to find out why JR Z, BUF_PBCD4 ADD HL,HL ; HL x 2 : We shift the number being tested left, - LD D,H ; : rrather than shifting DE right + LD D,H ; : rather than shifting DE right LD E,L ; : This makes a lot of sense ADD HL,HL ; HL x 4 ADD HL,HL ; HL x 8 diff --git a/patch.asm b/patch.asm index 46fa1a6..2323507 100644 --- a/patch.asm +++ b/patch.asm @@ -121,6 +121,8 @@ GETIME: PUSH IX RET ; PUTCSR: move to cursor to x=DE, y=HL +; TAB(x,y) Must be identical to VDU 31,x,y +; See https://mdfs.net/Software/BBCBasic/Porting/VDUSpecs ; PUTCSR: LD A, 1Fh ; TAB RST.LIS 10h @@ -175,16 +177,21 @@ OSRDCH: MOSCALL mos_getkey ; Read keyboard ; If carry set A = character ; Destroys: A,H,L,F ; -OSKEY: MOSCALL mos_getkey ; Read keyboard +OSKEY: BIT 7,H + JR NZ,OSKEY1 + LD HL,0 ; Negative INKEY not supported, return 0 + AND A + RET +OSKEY1 MOSCALL mos_getkey ; Read keyboard OR A ; If we have a character JR NZ, $F ; Then process it LD A,H ; Check if HL is 0 (this is passed by INKEY() function - OR L - RET Z ; If it is then ret + OR L ; Also sets CLC for timeout + RET Z ; If it is then return HALT ; Bit of a bodge so this is timed in ms DEC HL ; Decrement the counter and JR OSKEY ; loop -$$: CP 1BH ; If we are not pressing ESC, +$$: CP 1BH ; If we haven't pressed ESC, SCF ; then flag we've got a character RET NZ ; @@ -209,6 +216,8 @@ ESCTEST: MOSCALL mos_getkey ; Read keyboard ; ; TRAP ; This is called whenever BASIC needs to check for ESC +; NOTE This is called between every statement, so polling manually can slow the system quite a bit +; Could use a ticker to only actually test every X calls. ; TRAP: CALL ESCTEST ; Read keyboard, test for ESC, set FLAGS ; @@ -224,10 +233,11 @@ LTRAP: LD A,(FLAGS) ; Get FLAGS ;FILENAME.BBC is automatically CHAINed. ; Outputs: DE = initial value of HIMEM (top of RAM) ; HL = initial value of PAGE (user program) -; Z-flag reset indicates AUTO-RUN. +; NZ = filename passed for AUTO-RUN +; Z = no filename passed ; Destroys: A,D,E,H,L,F ; -OSINIT: XOR A +OSINIT: XOR A ; Z=no filename LD (FLAGS), A ; Clear flags and set F = Z LD HL, USER LD DE, RAM_Top @@ -411,13 +421,17 @@ STAR_FX: CALL ASC_TO_NUMBER ; C: FX # LD A, C ; A: FX #, and fall through to OSBYTE ; ; OSBYTE -; A: FX # +; A: OSBYTE/FX number ; L: First parameter ; H: Second parameter ; -OSBYTE: CP 13H ; We've only got one *FX command at the moment - JR Z, OSBYTE_13 ; *FX 13 - JP HUH ; Anything else trips an error +OSBYTE: CP 13H ; Check for calls explicitly + JR Z, OSBYTE_13 ; OSBYTE 19/*FX 19 + CP 00H + JR Z, OSBYTE_00 ; OSBYTE 0 + RET ; Anything else, just exit +: NOTE *FX may generate an error for unsupported calls, but OSBYTE must *NOT*. +; Constructs such as A%=25:CALL &FFF4 must *NOT* generate an error. ; OSBYTE 0x13 (FX 19): Wait for vertical blank interrupt ; @@ -430,6 +444,14 @@ $$: CP.LIL A, (IX + sysvar_time + 0) LD L, 0 ; Returns 0 JP COUNT0 +OSBYTE_00: LD L, 24 ; CP/M-like system, must return %00011xxx + JP COUNT0 ; See https://beebwiki.mdfs.net/OSBYTE_%2600 +; Programs must be able to do: +; A%=0:X%=1:os%=((USR&FFF4)AND&FF00)DIV256 +; d$=".":s$="/":IF(os%AND-24):d$="/":s$=".":IF(os%AND-32):d$="\" +; filename$=name$+s$+ext$ + + ;OSLOAD - Load an area of memory from a file. ; Inputs: HL addresses filename (CR terminated) ; DE = address at which to load diff --git a/ram.asm b/ram.asm index 63db8dc..f3cf4c8 100644 --- a/ram.asm +++ b/ram.asm @@ -94,6 +94,9 @@ INCREM: DS 1 ; AUTO INCREMENT ; Extra Agon-implementation specific system variables ; FLAGS: DS 1 ; Flags: B7=ESC PRESSED, B6=ESC DISABLED, B4=COPY PRESSED +; NOTE: FLAGS is normally USER-1, accessible as ?(PAGE-1). +; NOTE: ACS string buffer is normally USER-768, accessible as $(PAGE-768) +; ;TIME: DS 4 ;KEY_CODE: DS 1 ;VDU_BUFFER: DS 8 ; 8 bytes of temporary storage for the VDU buffer diff --git a/sorry.asm b/sorry.asm index af7d7b6..bbac430 100644 --- a/sorry.asm +++ b/sorry.asm @@ -27,3 +27,5 @@ PUTIMS: CALL EXTERR DEFB "Sorry" DEFB 0 + +; Should really just return silently