Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion agon_graphics.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -270,13 +285,18 @@ 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)
JR PLOT_1 ; Plot

; 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?
Expand Down
9 changes: 8 additions & 1 deletion agon_sound.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion exec.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion init.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -74,3 +74,5 @@ $$: LD (HL), E
RET


; The NMI vector at 0066h also not currently used by AGON

13 changes: 7 additions & 6 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
;
Expand Down Expand Up @@ -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.
Expand Down
28 changes: 5 additions & 23 deletions misc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
42 changes: 32 additions & 10 deletions patch.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
;
Expand All @@ -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
;
Expand All @@ -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
Expand Down Expand Up @@ -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
;
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions ram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sorry.asm
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ PUTIMS:
CALL EXTERR
DEFB "Sorry"
DEFB 0

; Should really just return silently