Code-style fixes as per PR feedback
This commit is contained in:
@@ -38,7 +38,7 @@ SEGMENTS {
|
|||||||
|
|
||||||
# Allow data between bitmap and top of memory to be used as a second BSS
|
# Allow data between bitmap and top of memory to be used as a second BSS
|
||||||
# space. Define symbols for it so that it can be supplied to _heapadd().
|
# space. Define symbols for it so that it can be supplied to _heapadd().
|
||||||
HIBSS: load = HIRAM, type = bss, optional = yes, define = yes;
|
HIBSS: load = HIRAM, type = bss, optional = yes, define = yes;
|
||||||
}
|
}
|
||||||
FEATURES {
|
FEATURES {
|
||||||
CONDES: type = constructor,
|
CONDES: type = constructor,
|
||||||
|
|||||||
@@ -58,20 +58,20 @@ L1: lda sp,x
|
|||||||
|
|
||||||
; Set up the IRQ vector in the banked RAM; and, switch off the ROM.
|
; Set up the IRQ vector in the banked RAM; and, switch off the ROM.
|
||||||
|
|
||||||
ldx #<IRQ
|
lda #<IRQ
|
||||||
ldy #>IRQ
|
ldx #>IRQ
|
||||||
sei ; No ints, handler not yet in place
|
sei ; No ints, handler not yet in place
|
||||||
sta ENABLE_RAM
|
sta ENABLE_RAM
|
||||||
stx $FFFE ; Install interrupt handler
|
sta $FFFE ; Install interrupt handler
|
||||||
sty $FFFF
|
stx $FFFF
|
||||||
ldx IRQVec
|
lda IRQVec
|
||||||
ldy IRQVec+1
|
ldx IRQVec+1
|
||||||
stx IRQInd+1
|
sta IRQInd+1
|
||||||
sty IRQInd+2
|
stx IRQInd+2
|
||||||
ldx #<IRQStub
|
lda #<IRQStub
|
||||||
ldy #>IRQStub
|
ldx #>IRQStub
|
||||||
stx IRQVec
|
sta IRQVec
|
||||||
sty IRQVec+1
|
stx IRQVec+1
|
||||||
|
|
||||||
cli ; Allow interrupts
|
cli ; Allow interrupts
|
||||||
|
|
||||||
@@ -194,18 +194,20 @@ nohandler:
|
|||||||
jmp (BRKVec) ; Jump indirect to the break vector
|
jmp (BRKVec) ; Jump indirect to the break vector
|
||||||
|
|
||||||
|
|
||||||
; IRQ stub called by the Kernal IRQ handler, via $314.
|
; IRQ stub installed at $314, called by our handler above if RAM is banked in,
|
||||||
|
; or the Kernal IRQ handler if ROM is banked in.
|
||||||
|
|
||||||
; If we have handlers, call them. We will use a flag here instead of loading
|
; If we have handlers, call them. We will use a flag here instead of loading
|
||||||
; __INTERRUPTOR_COUNT__ directly, since the condes function is not reentrant.
|
; __INTERRUPTOR_COUNT__ directly, since the condes function is not reentrant.
|
||||||
; The irqcount flag will be set/reset from the main code, to avoid races.
|
; The irqcount flag will be set/reset from the main code, to avoid races.
|
||||||
IRQStub:
|
IRQStub:
|
||||||
cld ; Just to be sure
|
cld ; Just to be sure
|
||||||
sta ENABLE_RAM
|
sta ENABLE_RAM
|
||||||
ldy irqcount
|
ldy irqcount
|
||||||
beq @L1
|
beq @L1
|
||||||
jsr callirq_y ; Call the IRQ functions
|
jsr callirq_y ; Call the IRQ functions
|
||||||
@L1: sta ENABLE_ROM
|
@L1: sta ENABLE_ROM
|
||||||
jmp (IRQInd+1) ; Jump to the saved IRQ vector
|
jmp (IRQInd+1) ; Jump to the saved IRQ vector
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Data
|
; Data
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ SendBuf: .res 256
|
|||||||
|
|
||||||
; Tables used to translate RS232 params into register values
|
; Tables used to translate RS232 params into register values
|
||||||
|
|
||||||
BaudTable: ; bit7 = 1 means setting is invalid
|
BaudTable: ; Bit7 = 1 means setting is invalid
|
||||||
.byte $FF ; SER_BAUD_45_5
|
.byte $FF ; SER_BAUD_45_5
|
||||||
.byte $01 ; SER_BAUD_50
|
.byte $01 ; SER_BAUD_50
|
||||||
.byte $02 ; SER_BAUD_75
|
.byte $02 ; SER_BAUD_75
|
||||||
@@ -353,26 +353,26 @@ SER_IOCTL:
|
|||||||
;
|
;
|
||||||
|
|
||||||
SER_IRQ:
|
SER_IRQ:
|
||||||
lda ACIA_STATUS ;(4) ;status ;check for byte received
|
lda ACIA_STATUS ; (4) Check for byte received
|
||||||
and #$08 ;(2)
|
and #$08 ; (2)
|
||||||
beq @L9 ;(2*)
|
beq @L9 ; (2*)
|
||||||
|
|
||||||
@L1: lda ACIA_DATA ;(4) data ;get byte and put into receive buffer
|
lda ACIA_DATA ; (4) Get byte and put into receive buffer
|
||||||
ldy RecvTail ;(4)
|
ldy RecvTail ; (4)
|
||||||
ldx RecvFreeCnt ;(4)
|
ldx RecvFreeCnt ; (4)
|
||||||
beq @L3 ;(2*) Jump if no space in receive buffer
|
beq @L3 ; (2*) Jump if no space in receive buffer
|
||||||
sta RecvBuf,y ;(5)
|
sta RecvBuf,y ; (5)
|
||||||
inc RecvTail ;(6)
|
inc RecvTail ; (6)
|
||||||
dec RecvFreeCnt ;(6)
|
dec RecvFreeCnt ; (6)
|
||||||
cpx #33 ;(2) check for buffer space low
|
cpx #33 ; (2) Check for buffer space low
|
||||||
bcc @L2 ;(2*)
|
bcc @L2 ; (2*)
|
||||||
rts ; Return with carry set (interrupt handled)
|
rts ; Return with carry set (interrupt handled)
|
||||||
|
|
||||||
; Assert flow control if buffer space too low
|
; Assert flow control if buffer space too low
|
||||||
|
|
||||||
@L2: lda RtsOff ;(3) assert flow control if buffer space too low
|
@L2: lda RtsOff ; (3)
|
||||||
sta ACIA_CMD ;(4) command
|
sta ACIA_CMD ; (4)
|
||||||
sta Stopped ;(3)
|
sta Stopped ; (3)
|
||||||
@L3: sec ; Interrupt handled
|
@L3: sec ; Interrupt handled
|
||||||
@L9: rts
|
@L9: rts
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ SER_IRQ:
|
|||||||
@L2: lda ACIA_STATUS
|
@L2: lda ACIA_STATUS
|
||||||
and #$10
|
and #$10
|
||||||
bne @L4
|
bne @L4
|
||||||
bit tmp1 ;keep trying if must try hard
|
bit tmp1 ; Keep trying if must try hard
|
||||||
bmi @L0
|
bmi @L0
|
||||||
@L3: rts
|
@L3: rts
|
||||||
|
|
||||||
|
|||||||
@@ -129,11 +129,11 @@ CHARROM := $D000 ; Character rom base address
|
|||||||
; bitmap at $E000 like we do on the C64, and have to use the next lowest
|
; bitmap at $E000 like we do on the C64, and have to use the next lowest
|
||||||
; position at $C000.
|
; position at $C000.
|
||||||
|
|
||||||
LBASE := $0800 ; Luminance memory base address
|
LBASE := $0800 ; Luminance memory base address
|
||||||
VBASE := $C000 ; Bitmap base address
|
VBASE := $C000 ; Bitmap base address
|
||||||
|
|
||||||
CBASE := LBASE + $400 ; Chrominance memory base address (fixed relative to LBASE)
|
CBASE := LBASE + $400 ; Chrominance memory base address (fixed relative to LBASE)
|
||||||
CHRBASE := $0800 ; Base address of text mode data
|
CHRBASE := $0800 ; Base address of text mode data
|
||||||
|
|
||||||
.assert LBASE .mod $0800 = 0, error, "Luma/Chroma memory base address must be a multiple of 2K"
|
.assert LBASE .mod $0800 = 0, error, "Luma/Chroma memory base address must be a multiple of 2K"
|
||||||
.assert VBASE .mod $2000 = 0, error, "Bitmap base address must be a multiple of 8K"
|
.assert VBASE .mod $2000 = 0, error, "Bitmap base address must be a multiple of 8K"
|
||||||
@@ -151,7 +151,7 @@ CHRBASE := $0800 ; Base address of text mode data
|
|||||||
;
|
;
|
||||||
|
|
||||||
INSTALL:
|
INSTALL:
|
||||||
; rts ; fall through
|
; rts ; Fall through
|
||||||
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
@@ -216,7 +216,7 @@ INIT:
|
|||||||
;
|
;
|
||||||
|
|
||||||
DONE: lda $FF12
|
DONE: lda $FF12
|
||||||
ora #%00000100 ; fetch from ROM
|
ora #%00000100 ; Fetch from ROM
|
||||||
sta $FF12
|
sta $FF12
|
||||||
|
|
||||||
.if LBASE <> CHRBASE
|
.if LBASE <> CHRBASE
|
||||||
@@ -229,7 +229,7 @@ DONE: lda $FF12
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
lda $FF06
|
lda $FF06
|
||||||
and #%11011111 ; exit bitmap mode
|
and #%11011111 ; Exit bitmap mode
|
||||||
sta $FF06
|
sta $FF06
|
||||||
|
|
||||||
rts
|
rts
|
||||||
@@ -306,7 +306,7 @@ CLEAR: ldy #$00
|
|||||||
;
|
;
|
||||||
|
|
||||||
SETVIEWPAGE:
|
SETVIEWPAGE:
|
||||||
; rts ; fall through
|
; rts ; Fall through
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
|
; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
|
||||||
@@ -472,14 +472,14 @@ GETPIXEL:
|
|||||||
|
|
||||||
LINE:
|
LINE:
|
||||||
|
|
||||||
@CHECK: lda X2 ;Make sure x1<x2
|
@CHECK: lda X2 ; Make sure x1<x2
|
||||||
sec
|
sec
|
||||||
sbc X1
|
sbc X1
|
||||||
tax
|
tax
|
||||||
lda X2+1
|
lda X2+1
|
||||||
sbc X1+1
|
sbc X1+1
|
||||||
bpl @CONT
|
bpl @CONT
|
||||||
lda Y2 ;If not, swap P1 and P2
|
lda Y2 ; If not, swap P1 and P2
|
||||||
ldy Y1
|
ldy Y1
|
||||||
sta Y1
|
sta Y1
|
||||||
sty Y2
|
sty Y2
|
||||||
@@ -500,19 +500,19 @@ LINE:
|
|||||||
@CONT: sta DX+1
|
@CONT: sta DX+1
|
||||||
stx DX
|
stx DX
|
||||||
|
|
||||||
ldx #$C8 ;INY
|
ldx #$C8 ; INY
|
||||||
lda Y2 ;Calculate dy
|
lda Y2 ; Calculate dy
|
||||||
sec
|
sec
|
||||||
sbc Y1
|
sbc Y1
|
||||||
tay
|
tay
|
||||||
lda Y2+1
|
lda Y2+1
|
||||||
sbc Y1+1
|
sbc Y1+1
|
||||||
bpl @DYPOS ;Is y2>=y1?
|
bpl @DYPOS ; Is y2>=y1?
|
||||||
lda Y1 ;Otherwise dy=y1-y2
|
lda Y1 ; Otherwise dy=y1-y2
|
||||||
sec
|
sec
|
||||||
sbc Y2
|
sbc Y2
|
||||||
tay
|
tay
|
||||||
ldx #$88 ;DEY
|
ldx #$88 ; DEY
|
||||||
|
|
||||||
@DYPOS: sty DY ; 8-bit DY -- FIX ME?
|
@DYPOS: sty DY ; 8-bit DY -- FIX ME?
|
||||||
stx YINCDEC
|
stx YINCDEC
|
||||||
@@ -524,8 +524,8 @@ LINE:
|
|||||||
sta CHUNK
|
sta CHUNK
|
||||||
|
|
||||||
ldx DY
|
ldx DY
|
||||||
cpx DX ;Who's bigger: dy or dx?
|
cpx DX ; Who's bigger: dy or dx?
|
||||||
bcc STEPINX ;If dx, then...
|
bcc STEPINX ; If dx, then...
|
||||||
lda DX+1
|
lda DX+1
|
||||||
bne STEPINX
|
bne STEPINX
|
||||||
|
|
||||||
@@ -543,14 +543,14 @@ LINE:
|
|||||||
; Y1 AND #$07
|
; Y1 AND #$07
|
||||||
STEPINY:
|
STEPINY:
|
||||||
lda #00
|
lda #00
|
||||||
sta OLDCHUNK ;So plotting routine will work right
|
sta OLDCHUNK ; So plotting routine will work right
|
||||||
lda CHUNK
|
lda CHUNK
|
||||||
lsr ;Strip the bit
|
lsr ; Strip the bit
|
||||||
eor CHUNK
|
eor CHUNK
|
||||||
sta CHUNK
|
sta CHUNK
|
||||||
txa
|
txa
|
||||||
beq YCONT2 ;If dy=0, it's just a point
|
beq YCONT2 ; If dy=0, it's just a point
|
||||||
@CONT: lsr ;Init counter to dy/2
|
@CONT: lsr ; Init counter to dy/2
|
||||||
;
|
;
|
||||||
; Main loop
|
; Main loop
|
||||||
;
|
;
|
||||||
@@ -562,30 +562,30 @@ YLOOP: sta TEMP
|
|||||||
eor (POINT),y
|
eor (POINT),y
|
||||||
sta (POINT),y
|
sta (POINT),y
|
||||||
YINCDEC:
|
YINCDEC:
|
||||||
iny ;Advance Y coordinate
|
iny ; Advance Y coordinate
|
||||||
cpy #8
|
cpy #8
|
||||||
bcc @CONT ;No prob if Y=0..7
|
bcc @CONT ; No prob if Y=0..7
|
||||||
jsr FIXY
|
jsr FIXY
|
||||||
@CONT: lda TEMP ;Restore A
|
@CONT: lda TEMP ; Restore A
|
||||||
sec
|
sec
|
||||||
sbc DX
|
sbc DX
|
||||||
bcc YFIXX
|
bcc YFIXX
|
||||||
YCONT: dex ;X is counter
|
YCONT: dex ; X is counter
|
||||||
bne YLOOP
|
bne YLOOP
|
||||||
YCONT2: lda (POINT),y ;Plot endpoint
|
YCONT2: lda (POINT),y ; Plot endpoint
|
||||||
eor BITMASK
|
eor BITMASK
|
||||||
and CHUNK
|
and CHUNK
|
||||||
eor (POINT),y
|
eor (POINT),y
|
||||||
sta (POINT),y
|
sta (POINT),y
|
||||||
rts
|
rts
|
||||||
|
|
||||||
YFIXX: ;x=x+1
|
YFIXX: ; X=x+1
|
||||||
adc DY
|
adc DY
|
||||||
lsr CHUNK
|
lsr CHUNK
|
||||||
bne YCONT ;If we pass a column boundary...
|
bne YCONT ; If we pass a column boundary...
|
||||||
ror CHUNK ;then reset CHUNK to $80
|
ror CHUNK ; Then reset CHUNK to $80
|
||||||
sta TEMP2
|
sta TEMP2
|
||||||
lda POINT ;And add 8 to POINT
|
lda POINT ; And add 8 to POINT
|
||||||
adc #8
|
adc #8
|
||||||
sta POINT
|
sta POINT
|
||||||
bcc @CONT
|
bcc @CONT
|
||||||
@@ -603,34 +603,33 @@ YFIXX: ;x=x+1
|
|||||||
|
|
||||||
.bss
|
.bss
|
||||||
COUNTHI:
|
COUNTHI:
|
||||||
.byte $00 ;Temporary counter
|
.byte $00 ; Temporary counter, only used once.
|
||||||
;only used once
|
|
||||||
.code
|
.code
|
||||||
STEPINX:
|
STEPINX:
|
||||||
ldx DX
|
ldx DX
|
||||||
lda DX+1
|
lda DX+1
|
||||||
sta COUNTHI
|
sta COUNTHI
|
||||||
cmp #$80
|
cmp #$80
|
||||||
ror ;Need bit for initialization
|
ror ; Need bit for initialization
|
||||||
sta Y1 ;High byte of counter
|
sta Y1 ; High byte of counter
|
||||||
txa
|
txa
|
||||||
bne @CONT ;Could be $100
|
bne @CONT ; Could be $100
|
||||||
dec COUNTHI
|
dec COUNTHI
|
||||||
@CONT: ror
|
@CONT: ror
|
||||||
;
|
;
|
||||||
; Main loop
|
; Main loop
|
||||||
;
|
;
|
||||||
XLOOP: lsr CHUNK
|
XLOOP: lsr CHUNK
|
||||||
beq XFIXC ;If we pass a column boundary...
|
beq XFIXC ; If we pass a column boundary...
|
||||||
XCONT1: sbc DY
|
XCONT1: sbc DY
|
||||||
bcc XFIXY ;Time to step in Y?
|
bcc XFIXY ; Time to step in Y?
|
||||||
XCONT2: dex
|
XCONT2: dex
|
||||||
bne XLOOP
|
bne XLOOP
|
||||||
dec COUNTHI ;High bits set?
|
dec COUNTHI ; High bits set?
|
||||||
bpl XLOOP
|
bpl XLOOP
|
||||||
|
|
||||||
lsr CHUNK ;Advance to last point
|
lsr CHUNK ; Advance to last point
|
||||||
jmp LINEPLOT ;Plot the last chunk
|
jmp LINEPLOT ; Plot the last chunk
|
||||||
;
|
;
|
||||||
; CHUNK has passed a column, so plot and increment pointer
|
; CHUNK has passed a column, so plot and increment pointer
|
||||||
; and fix up CHUNK, OLDCHUNK.
|
; and fix up CHUNK, OLDCHUNK.
|
||||||
@@ -652,22 +651,22 @@ XFIXC: sta TEMP
|
|||||||
; Check to make sure there isn't a high bit, plot chunk,
|
; Check to make sure there isn't a high bit, plot chunk,
|
||||||
; and update Y-coordinate.
|
; and update Y-coordinate.
|
||||||
;
|
;
|
||||||
XFIXY: dec Y1 ;Maybe high bit set
|
XFIXY: dec Y1 ; Maybe high bit set
|
||||||
bpl XCONT2
|
bpl XCONT2
|
||||||
adc DX
|
adc DX
|
||||||
sta TEMP
|
sta TEMP
|
||||||
lda DX+1
|
lda DX+1
|
||||||
adc #$FF ;Hi byte
|
adc #$FF ; Hi byte
|
||||||
sta Y1
|
sta Y1
|
||||||
|
|
||||||
jsr LINEPLOT ;Plot chunk
|
jsr LINEPLOT ; Plot chunk
|
||||||
lda CHUNK
|
lda CHUNK
|
||||||
sta OLDCHUNK
|
sta OLDCHUNK
|
||||||
|
|
||||||
lda TEMP
|
lda TEMP
|
||||||
XINCDEC:
|
XINCDEC:
|
||||||
iny ;Y-coord
|
iny ; Y-coord
|
||||||
cpy #8 ;0..7 is ok
|
cpy #8 ; 0..7 is ok
|
||||||
bcc XCONT2
|
bcc XCONT2
|
||||||
sta TEMP
|
sta TEMP
|
||||||
jsr FIXY
|
jsr FIXY
|
||||||
@@ -692,11 +691,11 @@ LINEPLOT: ; Plot the line chunk
|
|||||||
; Subroutine to fix up pointer when Y decreases through
|
; Subroutine to fix up pointer when Y decreases through
|
||||||
; zero or increases through 7.
|
; zero or increases through 7.
|
||||||
;
|
;
|
||||||
FIXY: cpy #255 ;Y=255 or Y=8
|
FIXY: cpy #255 ; Y=255 or Y=8
|
||||||
beq @DECPTR
|
beq @DECPTR
|
||||||
|
|
||||||
@INCPTR: ;Add 320 to pointer
|
@INCPTR: ; Add 320 to pointer
|
||||||
ldy #0 ;Y increased through 7
|
ldy #0 ; Y increased through 7
|
||||||
lda POINT
|
lda POINT
|
||||||
adc #<320
|
adc #<320
|
||||||
sta POINT
|
sta POINT
|
||||||
@@ -705,8 +704,8 @@ FIXY: cpy #255 ;Y=255 or Y=8
|
|||||||
sta POINT+1
|
sta POINT+1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@DECPTR: ;Okay, subtract 320 then
|
@DECPTR: ; Okay, subtract 320 then
|
||||||
ldy #7 ;Y decreased through 0
|
ldy #7 ; Y decreased through 0
|
||||||
lda POINT
|
lda POINT
|
||||||
sec
|
sec
|
||||||
sbc #<320
|
sbc #<320
|
||||||
@@ -815,28 +814,6 @@ TEXTSTYLE:
|
|||||||
;
|
;
|
||||||
|
|
||||||
OUTTEXT:
|
OUTTEXT:
|
||||||
|
|
||||||
; Calculate a pointer to the representation of the character in the
|
|
||||||
; character ROM
|
|
||||||
|
|
||||||
; ldx #((>(CHARROM + $0800)) >> 3)
|
|
||||||
; ldy #0
|
|
||||||
; lda (TEXT),y
|
|
||||||
; bmi @L1
|
|
||||||
; ldx #((>(CHARROM + $0000)) >> 3)
|
|
||||||
; @L1: stx ptr4+1
|
|
||||||
; asl a
|
|
||||||
; rol ptr4+1
|
|
||||||
; asl a
|
|
||||||
; rol ptr4+1
|
|
||||||
; asl a
|
|
||||||
; rol ptr4+1
|
|
||||||
; sta ptr4
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
@@ -862,10 +839,10 @@ CALC: lda Y1
|
|||||||
ror POINT
|
ror POINT
|
||||||
cmp #$80
|
cmp #$80
|
||||||
ror
|
ror
|
||||||
ror POINT ; row*64
|
ror POINT ; Row * 64
|
||||||
adc TEMP2 ; +row*256
|
adc TEMP2 ; + Row * 256
|
||||||
clc
|
clc
|
||||||
adc #>VBASE ; +bitmap base
|
adc #>VBASE ; + Bitmap base
|
||||||
sta POINT+1
|
sta POINT+1
|
||||||
|
|
||||||
lda X1
|
lda X1
|
||||||
|
|||||||
Reference in New Issue
Block a user