From 641a609cf332bb4372a5d76a167724f5c0951086 Mon Sep 17 00:00:00 2001 From: Greg King Date: Tue, 16 Jul 2013 00:30:56 -0400 Subject: [PATCH 1/3] Moved common symbol names out of sources, and into a global include file. --- asminc/atmos.inc | 63 ++++++++++++++++++++++++++---- libsrc/atmos/joy/atmos-pase.s | 31 +++++++-------- libsrc/atmos/mainargs.s | 16 ++++---- libsrc/atmos/ser/atmos-acia.s | 41 ++++++++----------- libsrc/atmos/tgi/atmos-228-200-3.s | 18 +-------- libsrc/atmos/tgi/atmos-240-200-2.s | 28 ++++--------- 6 files changed, 105 insertions(+), 92 deletions(-) diff --git a/asminc/atmos.inc b/asminc/atmos.inc index 446f2e11c..9ab50931d 100644 --- a/asminc/atmos.inc +++ b/asminc/atmos.inc @@ -1,32 +1,81 @@ ; -; Oric atmos zeropage and ROM definitions +; Oric Atmos definitions +; BASIC 1.1 addresses ; +; --------------------------------------------------------------------------- +; Constants + +FNAME_LEN = 16 ; maximum length of file-name + + ; --------------------------------------------------------------------------- ; Zero page +BASIC_BUF := $35 ; --------------------------------------------------------------------------- ; Low memory CAPSLOCK := $20C +PATTERN := $213 IRQVec := $245 CURS_Y := $268 CURS_X := $269 STATUS := $26A TIMER3 := $276 +CFOUND_NAME := $293 KEYBUF := $2DF +PARAM1 := $2E1 ; & $2E2 +PARAM2 := $2E3 ; & $2E4 +PARAM3 := $2E5 ; & $2E6 + + +; --------------------------------------------------------------------------- +; I/O locations + +; 6522 +.struct VIA ; Versatile Interface Adapter + .res $0300 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + +; 6551 +.struct ACIA ; Asynchronous Communications Interface Adapter + .res $031C +DATA .byte +STATUS .byte +CMD .byte ; Command register +CTRL .byte ; Control register +.endstruct + +SCREEN := $BB80 ; --------------------------------------------------------------------------- ; ROM entries +TEXT := $EC21 +HIRES := $EC33 +CURSET := $F0C8 +CURMOV := $F0FD +DRAW := $F110 +CHAR := $F12D +POINT := $F1C8 +PAPER := $F204 +INK := $F210 PRINT := $F77C - - -; --------------------------------------------------------------------------- -; I/O - -SCREEN := $BB80 diff --git a/libsrc/atmos/joy/atmos-pase.s b/libsrc/atmos/joy/atmos-pase.s index c505a1b0f..0c657584b 100644 --- a/libsrc/atmos/joy/atmos-pase.s +++ b/libsrc/atmos/joy/atmos-pase.s @@ -1,14 +1,15 @@ ; ; P.A.S.E. joystick driver for the Atmos -; May be used multiple times when linked to the statically application. +; Can be used multiple times when statically linked to the application. ; -; Stefan Haubenthal, 2009-12-21 -; Based on Ullrich von Bassewitz, 2002-12-20 +; 2002-12-20, Based on Ullrich von Bassewitz's code. +; 2009-12-21, Stefan Haubenthal +; 2013-07-15, Greg King ; .include "joy-kernel.inc" .include "joy-error.inc" -; .include "atmos.inc" + .include "atmos.inc" ; ------------------------------------------------------------------------ @@ -49,10 +50,6 @@ JOY_COUNT = 2 ; Number of joysticks we support -PRA = $0301 -DDRA = $0303 -PRA2 = $030F - ; ------------------------------------------------------------------------ ; Data. @@ -99,24 +96,24 @@ COUNT: READ: tay - lda PRA + lda VIA::PRA pha - lda DDRA + lda VIA::DDRA pha lda #%11000000 - sta DDRA + sta VIA::DDRA lda #%10000000 - sta PRA2 - lda PRA2 + sta VIA::PRA2 + lda VIA::PRA2 sta temp1 lda #%01000000 - sta PRA2 - lda PRA + sta VIA::PRA2 + lda VIA::PRA sta temp2 pla - sta DDRA + sta VIA::DDRA pla - sta PRA2 + sta VIA::PRA2 ldx #0 tya diff --git a/libsrc/atmos/mainargs.s b/libsrc/atmos/mainargs.s index 3e1f6467b..42a94da51 100644 --- a/libsrc/atmos/mainargs.s +++ b/libsrc/atmos/mainargs.s @@ -1,19 +1,19 @@ ; -; Ullrich von Bassewitz, 2003-03-07 -; Stefan Haubenthal, 2011-01-28 +; 2003-03-07, Ullrich von Bassewitz +; 2011-01-28, Stefan Haubenthal +; 2013-07-15, Greg King ; ; Setup arguments for main ; .constructor initmainargs, 24 .import __argc, __argv + + .include "atmos.inc" .macpack generic MAXARGS = 10 ; Maximum number of arguments allowed REM = $9d ; BASIC token-code -NAME_LEN = 16 ; maximum length of command-name -BASIC_BUF = $35 -FNAM = $293 ;--------------------------------------------------------------------------- @@ -29,8 +29,8 @@ FNAM = $293 ; Because the buffer, that we're copying into, was zeroed out, ; we don't need to add a NUL character. ; - ldy #NAME_LEN - 1 ; limit the length -L0: lda FNAM,y + ldy #FNAME_LEN - 1 ; limit the length +L0: lda CFOUND_NAME,y sta name,y dey bpl L0 @@ -114,7 +114,7 @@ done: lda # -; 2012-08-11, Greg King +; 2013-07-15, Greg King ; .include "zeropage.inc" @@ -79,21 +79,7 @@ ERROR: .res 1 ; Error code MODE: .res 1 ; Graphics mode PALETTE: .res 2 -; Constants and table -; BASIC 1.1 addresses -PATTERN := $213 -PARAM1 := $2E1 ; & $2E2 -PARAM2 := $2E3 ; & $2E4 -PARAM3 := $2E5 ; & $2E6 -TEXT := $EC21 -HIRES := $EC33 -CURSET := $F0C8 -CURMOV := $F0FD -DRAW := $F110 -CHAR := $F12D -POINT := $F1C8 -PAPER := $F204 -INK := $F210 +; Constant table .rodata diff --git a/libsrc/atmos/tgi/atmos-240-200-2.s b/libsrc/atmos/tgi/atmos-240-200-2.s index e58ac36d2..b5e0463d7 100644 --- a/libsrc/atmos/tgi/atmos-240-200-2.s +++ b/libsrc/atmos/tgi/atmos-240-200-2.s @@ -2,7 +2,7 @@ ; Graphics driver for the 240x200x2 monochrome mode on the Atmos ; ; Stefan Haubenthal -; 2012-08-11, Greg King +; 2013-07-15, Greg King ; .include "zeropage.inc" @@ -66,10 +66,10 @@ YSIZE = 8 ; System font height ; Variables mapped to the zero page segment variables. Some of these are ; used for passing parameters to the driver. -X1 = ptr1 -Y1 = ptr2 -X2 = ptr3 -Y2 = ptr4 +X1 := ptr1 +Y1 := ptr2 +X2 := ptr3 +Y2 := ptr4 ; Absolute variables used in the code @@ -78,19 +78,7 @@ Y2 = ptr4 ERROR: .res 1 ; Error code MODE: .res 1 ; Graphics mode -; Constants and tables -PARAM1 = $2E1 -PARAM2 = $2E3 -PARAM3 = $2E5 -TEXT = $EC21 -HIRES = $EC33 -CURSET = $F0C8 -CURMOV = $F0FD -DRAW = $F110 -CHAR = $F12D -POINT = $F1C8 -PAPER = $F204 -INK = $F210 +; Constant table .rodata @@ -152,7 +140,7 @@ INIT: ; Must set an error code: NO ; -DONE = TEXT +DONE := TEXT ; ------------------------------------------------------------------------ ; GETERROR: Return the error code in A and clear it. @@ -181,7 +169,7 @@ CONTROL: ; Must set an error code: NO ; -CLEAR = HIRES +CLEAR := HIRES ; ------------------------------------------------------------------------ ; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n). From 3574f3a742d67e688c4db59876cb26815662ee71 Mon Sep 17 00:00:00 2001 From: Greg King Date: Tue, 16 Jul 2013 01:48:57 -0400 Subject: [PATCH 2/3] Normalized some hexadecimal addresses. --- asminc/atmos.inc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/asminc/atmos.inc b/asminc/atmos.inc index 9ab50931d..ea6669243 100644 --- a/asminc/atmos.inc +++ b/asminc/atmos.inc @@ -19,18 +19,18 @@ BASIC_BUF := $35 ; --------------------------------------------------------------------------- ; Low memory -CAPSLOCK := $20C -PATTERN := $213 -IRQVec := $245 -CURS_Y := $268 -CURS_X := $269 -STATUS := $26A -TIMER3 := $276 -CFOUND_NAME := $293 -KEYBUF := $2DF -PARAM1 := $2E1 ; & $2E2 -PARAM2 := $2E3 ; & $2E4 -PARAM3 := $2E5 ; & $2E6 +CAPSLOCK := $020C +PATTERN := $0213 +IRQVec := $0245 +CURS_Y := $0268 +CURS_X := $0269 +STATUS := $026A +TIMER3 := $0276 +CFOUND_NAME := $0293 +KEYBUF := $02DF +PARAM1 := $02E1 ; & $02E2 +PARAM2 := $02E3 ; & $02E4 +PARAM3 := $02E5 ; & $02E6 ; --------------------------------------------------------------------------- From f02843f05d3478b8ef13b4cac90205dec4f204f3 Mon Sep 17 00:00:00 2001 From: Greg King Date: Fri, 26 Jul 2013 03:33:54 -0400 Subject: [PATCH 3/3] Replaced number literals in source code with meaningful symbol names. --- asminc/atmos.inc | 13 +++++++++++++ libsrc/atmos/_scrsize.s | 8 +++++--- libsrc/atmos/atmos_load.s | 16 ++++++++++------ libsrc/atmos/atmos_save.s | 18 +++++++++++------- libsrc/atmos/cgetc.s | 8 ++++---- libsrc/atmos/clrscr.s | 7 ++++--- libsrc/atmos/cputc.s | 13 +++++++------ libsrc/atmos/store_filename.s | 8 ++++++-- libsrc/atmos/tgi/atmos-240-200-2.s | 4 ++-- 9 files changed, 62 insertions(+), 33 deletions(-) diff --git a/asminc/atmos.inc b/asminc/atmos.inc index ea6669243..20bb806f1 100644 --- a/asminc/atmos.inc +++ b/asminc/atmos.inc @@ -7,6 +7,11 @@ ; --------------------------------------------------------------------------- ; Constants +SCREEN_XSIZE = 40 ; screen columns +SCREEN_YSIZE = 28 ; screen rows + +FUNCTKEY = $A5 + FNAME_LEN = 16 ; maximum length of file-name @@ -19,14 +24,22 @@ BASIC_BUF := $35 ; --------------------------------------------------------------------------- ; Low memory +MODEKEY := $0209 CAPSLOCK := $020C PATTERN := $0213 IRQVec := $0245 +JOINFLAG := $025A ; 0 = don't joiu, $4A = join BASIC programs +VERIFYFLAG := $025B ; 0 = load, 1 = verify CURS_Y := $0268 CURS_X := $0269 STATUS := $026A TIMER3 := $0276 +CFILE_NAME := $027F CFOUND_NAME := $0293 +FILESTART := $02A9 +FILEEND := $02AB +AUTORUN := $02AD ; $00 = only load, $C7 = autorun +LANGFLAG := $02AE ; $00 = BASIC, $80 = machine code KEYBUF := $02DF PARAM1 := $02E1 ; & $02E2 PARAM2 := $02E3 ; & $02E4 diff --git a/libsrc/atmos/_scrsize.s b/libsrc/atmos/_scrsize.s index 2dd58399d..7a7af33ee 100644 --- a/libsrc/atmos/_scrsize.s +++ b/libsrc/atmos/_scrsize.s @@ -1,15 +1,17 @@ ; -; Ullrich von Bassewitz, 2003-04-13 +; 2003-04-13, Ullrich von Bassewitz +; 2013-07-16, Greg King ; ; Screen size variables ; .export screensize + .include "atmos.inc" .proc screensize - ldx #40 - ldy #28 + ldx #SCREEN_XSIZE + ldy #SCREEN_YSIZE rts .endproc diff --git a/libsrc/atmos/atmos_load.s b/libsrc/atmos/atmos_load.s index 9e86373f3..b5bec3225 100644 --- a/libsrc/atmos/atmos_load.s +++ b/libsrc/atmos/atmos_load.s @@ -1,20 +1,24 @@ -; Stefan Haubenthal, 2012-05-06 -; based on code by Twilighte +; Based on code by Twilighte. +; 2012-05-06, Stefan Haubenthal +; 2013-07-22, Greg King +; ; void __fastcall__ atmos_load(const char* name); .export _atmos_load .import store_filename + .include "atmos.inc" + .proc _atmos_load sei jsr store_filename ldx #$00 - stx $02ad - stx $02ae - stx $025a - stx $025b + stx AUTORUN ; don't try to run the file + stx LANGFLAG ; BASIC + stx JOINFLAG ; don't join it to another BASIC program + stx VERIFYFLAG ; load the file jsr cload_bit cli rts diff --git a/libsrc/atmos/atmos_save.s b/libsrc/atmos/atmos_save.s index 0bd9e29cc..3d221f6fa 100644 --- a/libsrc/atmos/atmos_save.s +++ b/libsrc/atmos/atmos_save.s @@ -1,23 +1,27 @@ -; Stefan Haubenthal, 2012-05-06 -; based on code by Twilighte +; Based on code by Twilighte. +; 2012-05-06, Stefan Haubenthal +; 2013-07-22, Greg King +; ; void __fastcall__ atmos_save(const char* name, const void* start, const void* end); .export _atmos_save .import popax, store_filename + .include "atmos.inc" + .proc _atmos_save sei - sta $02ab ; file end lo - stx $02ac ; file end hi + sta FILEEND + stx FILEEND+1 jsr popax - sta $02a9 ; file start lo - stx $02aa ; file start hi + sta FILESTART + stx FILESTART+1 jsr popax jsr store_filename lda #00 - sta $02ad + sta AUTORUN jsr csave_bit cli rts diff --git a/libsrc/atmos/cgetc.s b/libsrc/atmos/cgetc.s index 38e7aa873..e13d143d2 100644 --- a/libsrc/atmos/cgetc.s +++ b/libsrc/atmos/cgetc.s @@ -1,5 +1,6 @@ ; -; Ullrich von Bassewitz, 2003-04-13 +; 2003-04-13, Ullrich von Bassewitz +; 2013-07-26, Greg King ; ; char cgetc (void); ; @@ -11,7 +12,6 @@ .include "atmos.inc" - ; ------------------------------------------------------------------------ ; @@ -41,8 +41,8 @@ @L2: and #$7F ; Mask out avail flag sta KEYBUF - ldy $209 - cpy #$A5 + ldy MODEKEY + cpy #FUNCTKEY bne @L3 ora #$80 ; FUNCT pressed diff --git a/libsrc/atmos/clrscr.s b/libsrc/atmos/clrscr.s index 9dce665e9..2230d6e0a 100644 --- a/libsrc/atmos/clrscr.s +++ b/libsrc/atmos/clrscr.s @@ -1,5 +1,6 @@ ; -; Ullrich von Bassewitz, 2003-04-13 +; 2003-04-13, Ullrich von Bassewitz +; 2013-07-16, Greg King ; .export _clrscr @@ -27,7 +28,7 @@ ; Clear full pages. Y is still zero - ldx #>(28*40) + ldx #>(SCREEN_YSIZE * SCREEN_XSIZE) lda #' ' @L1: sta (ptr2),y iny ; Bump low byte of address @@ -40,7 +41,7 @@ @L2: sta (ptr2),y iny - cpy #<(28*40) + cpy #<(SCREEN_YSIZE * SCREEN_XSIZE) bne @L2 rts diff --git a/libsrc/atmos/cputc.s b/libsrc/atmos/cputc.s index 9f65be500..a0ef14b70 100644 --- a/libsrc/atmos/cputc.s +++ b/libsrc/atmos/cputc.s @@ -1,5 +1,6 @@ ; -; Ullrich von Bassewitz, 2003-04-13 +; 2003-04-13, Ullrich von Bassewitz +; 2013-07-16, Greg King ; ; void cputcxy (unsigned char x, unsigned char y, char c); ; void cputc (char c); @@ -41,7 +42,7 @@ output: advance: iny - cpy #40 + cpy #SCREEN_XSIZE bne L3 inc CURS_Y ; new line ldy #0 ; + cr @@ -85,12 +86,12 @@ L3: sty CURS_X .rodata ScrTabLo: - .repeat 28, Line - .byte <(SCREEN + Line * 40) + .repeat SCREEN_YSIZE, Line + .byte <(SCREEN + Line * SCREEN_XSIZE) .endrep ScrTabHi: - .repeat 28, Line - .byte >(SCREEN + Line * 40) + .repeat SCREEN_YSIZE, Line + .byte >(SCREEN + Line * SCREEN_XSIZE) .endrep diff --git a/libsrc/atmos/store_filename.s b/libsrc/atmos/store_filename.s index cb6d8b933..41d1837f1 100644 --- a/libsrc/atmos/store_filename.s +++ b/libsrc/atmos/store_filename.s @@ -1,12 +1,16 @@ +; Helper function + .export store_filename .importzp ptr1 + .include "atmos.inc" + store_filename: sta ptr1 stx ptr1+1 - ldy #$0f ;store filename + ldy #FNAME_LEN - 1 ; store filename : lda (ptr1),y - sta $027f,y + sta CFILE_NAME,y dey bpl :- rts diff --git a/libsrc/atmos/tgi/atmos-240-200-2.s b/libsrc/atmos/tgi/atmos-240-200-2.s index b5e0463d7..762c7c02d 100644 --- a/libsrc/atmos/tgi/atmos-240-200-2.s +++ b/libsrc/atmos/tgi/atmos-240-200-2.s @@ -2,7 +2,7 @@ ; Graphics driver for the 240x200x2 monochrome mode on the Atmos ; ; Stefan Haubenthal -; 2013-07-15, Greg King +; 2013-07-16, Greg King ; .include "zeropage.inc" @@ -158,7 +158,7 @@ GETERROR: ; CONTROL: - sta $213 + sta PATTERN lda #TGI_ERR_OK sta ERROR rts