started cleanup of aliases, build system fixes

This commit is contained in:
FeralChild64 committed 2019-07-18 23:30:12 +02:00
1 parent eb12f33225
commit cf795d5f3c
25 files changed
+410 -355

No files matched your search

-131
View File
@@ -90,128 +90,6 @@
.alias RSSTAT $0297 ; RS-232 status
.alias pal_or_ntsc $02A6
;; Kernal vectors - interrupts
.alias CINV $0314
.alias CBINV $0316
.alias NMINV $0318
;; Kernal vectors - routines
.alias IOPEN $031A
.alias ICLOSE $031C
.alias ICHKIN $031E
.alias ICKOUT $0320
.alias ICLRCH $0322
.alias IBASIN $0324
.alias IBASOUT $0326
.alias ISTOP $0328
.alias IGETIN $032A
.alias ICLALL $032C
.alias USRCMD $032E
.alias ILOAD $0330
.alias ISAVE $0331
;; Kernal jump table
.alias JCINT $FF81
.alias JIOINIT $FF84
.alias JRAMTAS $FF87
.alias JRESTOR $FF8A
.alias JVECTOR $FF8D
.alias JSETMSG $FF90
.alias JSECOND $FF93
.alias JTKSA $FF96
.alias JMEMTOP $FF99
.alias JMEMBOT $FF9C
.alias JSCNKEY $FF9F
.alias JSETTMO $FFA2
.alias JACPTR $FFA5
.alias JCIOUT $FFA8
.alias JUNTLK $FFAB
.alias JUNLSN $FFAE
.alias JLISTEN $FFB1
.alias JTALK $FFB4
.alias JREADST $FFB7
.alias JSETFLS $FFBA
.alias JSETNAM $FFBD
.alias JOPEN $FFC0
.alias JCLOSE $FFC3
.alias JCHKIN $FFC6
.alias JCHKOUT $FFC9
.alias JCLRCHN $FFCC
.alias JCHRIN $FFCF
.alias JCHROUT $FFD2
.alias JLOAD $FFD5
.alias JSAVE $FFD8
.alias JSETTIM $FFDB
.alias JRDTIM $FFDE
.alias JSTOP $FFE1
.alias JGETIN $FFE4
.alias JCLALL $FFE7
.alias JUDTIM $FFEA
.alias JSCREEN $FFED
.alias JPLOT $FFF0
.alias JIOBASE $FFF3
;; Kernal error codes - returned in the A register
;; Described in 'Commodore 64 Programmer's Reference Guide', page 306
.alias K_ERR_ROUTINE_TERMINATED $00
.alias K_ERR_TOO_MANY_OPEN_FILES $01
.alias K_ERR_FILE_ALREADY_OPEN $02
.alias K_ERR_FILE_NOT_OPEN $03
.alias K_ERR_FILE_NOT_FOUND $04
.alias K_ERR_DEVICE_NOT_FOUND $05
.alias K_ERR_FILE_NOT_INPUT $06
.alias K_ERR_FILE_NOT_OUTPUT $07
.alias K_ERR_FILE_NAME_MISSING $08
.alias K_ERR_ILLEGAL_DEVICE_NUMBER $09
.alias K_ERR_TOP_MEM_RS232 $F0
;; Kernal status codes for READST routine (IOSTATUS)
;; Described in 'Commodore 64 Programmer's Reference Guide', page 292
;; For IEC devices
.alias K_STS_TIMEOUT_WRITE $01
.alias K_STS_TIMEOUT_READ $02
.alias K_STS_EOI $40
.alias K_STS_DEVICE_NOT_FOUND $80
;; For tape deck
.alias K_STS_SHORT_BLOCK $04
.alias K_STS_LONG_BLOCK $08
.alias K_STS_READ_ERROR $10
.alias K_STS_CHECKSUM_ERROR $20
.alias K_STS_END_OF_FILE $40
.alias K_STS_END_OF_TAPE $80
;; BASIC error codes, taken from http://sta.c64.org/cbm64baserr.html
.alias B_ERR_TOO_MANY_FILES $01
.alias B_ERR_FILE_OPEN $02
.alias B_ERR_FILE_NOT_OPEN $03
.alias B_ERR_FILE_NOT_FOUND $04
.alias B_ERR_DEVICE_NOT_PRESENT $05
.alias B_ERR_NOT_INPUT_FILE $06
.alias B_ERR_NOT_OUTPUT_FILE $07
.alias B_ERR_MISSING_FILENAME $08
.alias B_ERR_ILLEGAL_DEVICE_NUMBER $09
.alias B_ERR_NEXT_WITHOUT_FOR $0A
.alias B_ERR_SYNTAX $0B
.alias B_ERR_RETURN_WITHOUT_GOSUB $0C
.alias B_ERR_OUT_OF_DATA $0D
.alias B_ERR_ILLEGAL_QUANTITY $0E
.alias B_ERR_OVERFLOW $0F
.alias B_ERR_OUT_OF_MEMORY $10
.alias B_ERR_UNDEFD_STATEMENT $11
.alias B_ERR_BAD_SUBSCRIPT $12
.alias B_ERR_REDIMD_ARRAY $13
.alias B_ERR_DIVISION_BY_ZERO $14
.alias B_ERR_ILLEGAL_DIRECT $15
.alias B_ERR_TYPE_MISMATCH $16
.alias B_ERR_STRING_TOO_LONG $17
.alias B_ERR_FILE_DATA $18
.alias B_ERR_FORMULA_TOO_COMPLEX $19
.alias B_ERR_CANT_CONTINUE $1A
.alias B_ERR_UNDEFD_FUNCTION $1B
.alias B_ERR_VERIFY $1C
.alias B_ERR_LOAD $1D
.alias B_ERR_BREAK $1E
;; Under-ROM routines
;; (BASIC also includes them. XXX - We should de-duplicate them in a safe manner)
.alias missed_nmi_flag $2A7
@@ -221,12 +99,3 @@
.alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine
.alias memmap_normal tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine
;; CIA#2 - https://www.c64-wiki.com/wiki/CIA#CIA_2
.alias CI2PRA $DD00 ; VIC bank switching and IEC port
.alias BIT_CI2PRA_ATN_OUT $08 ; 1 - low (pulled), 0 - high (released)
.alias BIT_CI2PRA_CLK_OUT $10 ; 1 - low (pulled), 0 - high (released)
.alias BIT_CI2PRA_DAT_OUT $20 ; 1 - low (pulled), 0 - high (released)
.alias BIT_CI2PRA_CLK_IN $40 ; 0 - low (pulled), 1 - high (released)
.alias BIT_CI2PRA_DAT_IN $80 ; 0 - low (pulled), 1 - high (released)
+7 -7
View File
@@ -5,11 +5,11 @@ iec_pull_atn_clk_release_data:
;; hardware give some lines few more cycles to stabilize; see page 10 of
;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
lda CI2PRA
ora #BIT_CI2PRA_ATN_OUT ; pull
sta CI2PRA
ora #BIT_CI2PRA_CLK_OUT ; pull
sta CI2PRA
and #$FF - BIT_CI2PRA_DAT_OUT ; release
sta CI2PRA
lda CIA2_PRA
ora #BIT_CIA2_PRA_ATN_OUT ; pull
sta CIA2_PRA
ora #BIT_CIA2_PRA_CLK_OUT ; pull
sta CIA2_PRA
and #$FF - BIT_CIA2_PRA_DAT_OUT ; release
sta CIA2_PRA
rts
+5 -5
View File
@@ -5,9 +5,9 @@ iec_pull_clk_release_data:
;; hardware give some lines few more cycles to stabilize; see page 10 of
;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
lda CI2PRA
ora #BIT_CI2PRA_CLK_OUT ; pull
sta CI2PRA
and #$FF - BIT_CI2PRA_DAT_OUT ; release
sta CI2PRA
lda CIA2_PRA
ora #BIT_CIA2_PRA_CLK_OUT ; pull
sta CIA2_PRA
and #$FF - BIT_CIA2_PRA_DAT_OUT ; release
sta CIA2_PRA
rts
+7 -7
View File
@@ -5,11 +5,11 @@ iec_pull_data_release_atn_clk:
;; hardware give some lines few more cycles to stabilize; see page 10 of
;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
lda CI2PRA
ora #BIT_CI2PRA_DAT_OUT ; pull
sta CI2PRA
and #$FF - BIT_CI2PRA_CLK_OUT ; release
sta CI2PRA
and #$FF - BIT_CI2PRA_ATN_OUT ; release
sta CI2PRA
lda CIA2_PRA
ora #BIT_CIA2_PRA_DAT_OUT ; pull
sta CIA2_PRA
and #$FF - BIT_CIA2_PRA_CLK_OUT ; release
sta CIA2_PRA
and #$FF - BIT_CIA2_PRA_ATN_OUT ; release
sta CIA2_PRA
rts
+3 -3
View File
@@ -1,8 +1,8 @@
iec_release_atn:
lda CI2PRA
and #$FF - BIT_CI2PRA_ATN_OUT ; release
sta CI2PRA
lda CIA2_PRA
and #$FF - BIT_CIA2_PRA_ATN_OUT ; release
sta CIA2_PRA
rts
+7 -7
View File
@@ -5,12 +5,12 @@ iec_release_atn_clk_data:
;; hardware give some lines few more cycles to stabilize; see page 10 of
;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
lda CI2PRA
and #$FF - BIT_CI2PRA_ATN_OUT ; release
sta CI2PRA
and #$FF - BIT_CI2PRA_DAT_OUT ; release
sta CI2PRA
and #$FF - BIT_CI2PRA_CLK_OUT ; release
sta CI2PRA
lda CIA2_PRA
and #$FF - BIT_CIA2_PRA_ATN_OUT ; release
sta CIA2_PRA
and #$FF - BIT_CIA2_PRA_DAT_OUT ; release
sta CIA2_PRA
and #$FF - BIT_CIA2_PRA_CLK_OUT ; release
sta CIA2_PRA
rts
+5 -5
View File
@@ -5,9 +5,9 @@ iec_release_clk_data:
;; hardware give some lines few more cycles to stabilize; see page 10 of
;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
lda CI2PRA
and #$FF - BIT_CI2PRA_DAT_OUT ; release
sta CI2PRA
and #$FF - BIT_CI2PRA_CLK_OUT ; release
sta CI2PRA
lda CIA2_PRA
and #$FF - BIT_CIA2_PRA_DAT_OUT ; release
sta CIA2_PRA
and #$FF - BIT_CIA2_PRA_CLK_OUT ; release
sta CIA2_PRA
rts
+5 -5
View File
@@ -5,9 +5,9 @@ iec_release_clk_pull_data:
;; hardware give some lines few more cycles to stabilize; see page 10 of
;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
lda CI2PRA
ora #BIT_CI2PRA_DAT_OUT ; pull
sta CI2PRA
and #$FF - BIT_CI2PRA_CLK_OUT ; release
sta CI2PRA
lda CIA2_PRA
ora #BIT_CIA2_PRA_DAT_OUT ; pull
sta CIA2_PRA
and #$FF - BIT_CIA2_PRA_CLK_OUT ; release
sta CIA2_PRA
rts
+5 -5
View File
@@ -24,8 +24,8 @@ iec_rx_byte:
ldx #$11 ; 2 cycles
iec_rx_clk_wait1:
lda CI2PRA ; 4 cycles
rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit
lda CIA2_PRA ; 4 cycles
rol ; 2 cycles, to put CLK in as the last bit
bpl iec_rx_not_eoi ; 2 cycles if not jumped
dex ; 2 cycles
bne iec_rx_clk_wait1 ; 3 cycles if jumped
@@ -77,7 +77,7 @@ iec_rx_bit_loop:
;; Move data bit into C flag, and loop until bit 6 clears
;; i.e., the clock has been released.
* lda CI2PRA
* lda CIA2_PRA
rol
bpl -
@@ -90,8 +90,8 @@ iec_rx_bit_loop:
;; consider this a timeout
ldy #$19 ; 2 cycles
iec_rx_clk_wait2:
lda CI2PRA ; 4 cycles
rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit
lda CIA2_PRA ; 4 cycles
rol ; 2 cycles, to put CLK in as the last bit
bpl + ; 2 cycles if not jumped
dey ; 2 cycles
bne iec_rx_clk_wait2 ; 3 cycles if jumped
+4 -4
View File
@@ -1,7 +1,7 @@
iec_set_idle:
lda CI2PRA
ora #BIT_CI2PRA_CLK_OUT ; pull
and #$FF - BIT_CI2PRA_DAT_OUT - BIT_CI2PRA_ATN_OUT ; release
sta CI2PRA
lda CIA2_PRA
ora #BIT_CIA2_PRA_CLK_OUT ; pull
and #$FF - BIT_CIA2_PRA_DAT_OUT - BIT_CIA2_PRA_ATN_OUT ; release
sta CIA2_PRA
rts
+2 -2
View File
@@ -14,8 +14,8 @@ iec_turnaround_to_listen:
;; Wait for clock line to be pulled by the drive
ldx #$FF ; XXX should we really use that high number?
*
lda CI2PRA
rol ; to put BIT_CI2PRA_CLK_IN as the last (sign) bit
lda CIA2_PRA
rol ; to put BIT_CIA2_PRA_CLK_IN as the last (sign) bit
bpl +
dex
bne -
+2 -2
View File
@@ -21,8 +21,8 @@ iec_tx_byte:
;; All done - give device time to tell if they are busy by pulling DATA
;; They should do it within 1ms
ldx #$FF
* lda CI2PRA
;; BPL here is checking that bit 7 of $DD00 clears,
* lda CIA2_PRA
;; BPL here is checking that bit 7 clears,
;; i.e, that the DATA line is pulled by drive
bpl +
dex
+4 -4
View File
@@ -14,8 +14,8 @@ iec_tx_command:
jsr wait1ms
;; Did at least one device respond by pulling DATA?
lda CI2PRA
and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine
lda CIA2_PRA
and #BIT_CIA2_PRA_DAT_IN ; XXX try to optimize this, move to separate routine
beq +
;; No devices present on the bus, so we can immediately return with device not found
@@ -42,8 +42,8 @@ iec_tx_command:
;; flow here, but http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 6)
;; advices to just wait 1ms and check the DATA status
jsr wait1ms
lda CI2PRA
and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine
lda CIA2_PRA
and #BIT_CIA2_PRA_DAT_IN ; XXX try to optimize this, move to separate routine
beq +
;; XXX possible optimization of the flow above: for many commands it is enough
+3 -2
View File
@@ -1,6 +1,7 @@
iec_wait_for_clk_release:
lda CI2PRA
and #BIT_CI2PRA_CLK_IN
lda CIA2_PRA
and #BIT_CIA2_PRA_CLK_IN
beq iec_wait_for_clk_release
rts
+2 -1
View File
@@ -1,6 +1,7 @@
iec_wait_for_data_pull:
lda CI2PRA
lda CIA2_PRA
;; Check the highest bit, which is DATA IN,
;; (highest bit set = negative value)
bmi iec_wait_for_data_pull
+2 -1
View File
@@ -1,6 +1,7 @@
iec_wait_for_data_release:
lda CI2PRA
lda CIA2_PRA
;; Check the highest bit, which is DATA IN,
;; (highest bit set = negative value)
bpl iec_wait_for_data_release
+21 -21
View File
@@ -12,12 +12,12 @@ ramtas:
; C64 Programmer's Reference guide p291:
; Clear $0000-$0101, $0200-$03ff
; PGS: $0000, $0001 are CPU IO ports, so shouldn't get written to
LDY #$02
LDA #$00
ldy #$02
lda #$00
ramtas_l1:
STA $00,Y
INY
BNE ramtas_l1
sta $00,Y
iny
bne ramtas_l1
ramtas_l2:
;; How many ways are there to efficiently erase these two pages
;; of RAM? We would like to avoid any unnecessary byte similarity
@@ -25,41 +25,41 @@ ramtas_l2:
;; with the longer sequence of identicale bytes we see no basis for
;; it being copyrightable. Again, we just want to redue the attack
;; surface for any misguided suit.
STA $0300,Y
STA $0200,Y
INY
BNE ramtas_l2
sta $0300,Y
sta $0200,Y
iny
bne ramtas_l2
; allocate cassette buffer
;; "Mapping the C128", p61
lda #<$033C
STA cassette_buffer_ptr+0
sta cassette_buffer_ptr+0
lda #>$033C
STA cassette_buffer_ptr+1
sta cassette_buffer_ptr+1
; set screen address to $0400
; https://www.c64-wiki.com/wiki/Screen_RAM
; Since we are setting $D018, we also make sure we are using the
; ROM character set (C64 Programmer's Reference Guide p322)
LDA #$14
STA $D018
lda #$14
sta VIC_YMCSB
; Make sure we have the correct VIC-II memory bank for the screen to really be at $0400
; and not $4400, $8400 or $C400
; https://www.c64-wiki.com/wiki/VIC_bank#Selecting_VIC_banks
LDA $DD02
ORA #$03
STA $DD02
LDA $DD00
ORA #$03
STA $DD00
lda CIA2_DDRA
ora #$03
sta CIA2_DDRA
lda CIA2_PRA
ora #$03
sta CIA2_PRA
;; Set screen address pointer ("Compute's Mapping the 64" p238)
;; This is obvious boiler plate containing no creative input, but to avoid
;; unnecessarily similarity to the C64 KERNAL, we use X instead of A to do this,
;; and several following
LDX #>$0400
STX HIBASE
ldx #>$0400
stx HIBASE
;; Work out RAM size and put in MEMSTR and MEMSIZ
;; "Compute's Mapping the 64", p54