SHR code: move local temp vars to ZP

This commit is contained in:
Bobbi Webber-Manners 2023-01-04 19:28:21 -05:00
parent 0bb099bdfd
commit 5d96b7d115
3 changed files with 26 additions and 20 deletions

Binary file not shown.

View File

@ -36,6 +36,8 @@ A4H EQU $43
* Other ZP locations * Other ZP locations
ISRL EQU $02 ; Used for ISR only ISRL EQU $02 ; Used for ISR only
ISRH EQU $03 ; Used for ISR only ISRH EQU $03 ; Used for ISR only
SHRZP EQU $56 ; 25 bytes, persistent, SHR code only
TMPZP EQU $56+25 ; Temp scratch space for routines
* Used by XFER * Used by XFER
STRTL EQU $3ED STRTL EQU $3ED

View File

@ -15,6 +15,8 @@ SHRFONTXPLD EQU $A000 ; Explode SHR font to $E1:A000
****************************************************************************** ******************************************************************************
* 25 bytes of persistent storage
* TODO: Move to SHRZP
SHRPIXELS DB $00 ; Main memory copy of VDUPIXELS SHRPIXELS DB $00 ; Main memory copy of VDUPIXELS
SHRVDUQ DS 16 ; Main memory copy of VDUQ SHRVDUQ DS 16 ; Main memory copy of VDUQ
SHRGFXFGMASK DB $00 ; Foreground colour mask SHRGFXFGMASK DB $00 ; Foreground colour mask
@ -23,8 +25,6 @@ SHRGFXBGMASK DB $00 ; Background colour mask
SHRGFXACTION DB $00 ; GCOL action for point plotting SHRGFXACTION DB $00 ; GCOL action for point plotting
SHRXPIXEL DW $0000 ; Previous point in screen coords SHRXPIXEL DW $0000 ; Previous point in screen coords
SHRYPIXEL DW $0000 ; Previous point in screen coords SHRYPIXEL DW $0000 ; Previous point in screen coords
SHRTMPWRD DW $0000 ; Temp scratch space
* Explode font to generate SHRFONTXPLD table * Explode font to generate SHRFONTXPLD table
@ -422,14 +422,15 @@ SHRPLOTCLR EOR #$FF ; Invert bits
* x1 in A1L,A1H * x1 in A1L,A1H
* y1 in A2L * y1 in A2L
* Called in emulation mode. * Called in emulation mode.
* Uses TMPZP+0,+1
SHRLINE LDA A2L ; y1 SHRLINE LDA A2L ; y1
SEC SEC
SBC SHRYPIXEL ; Subtract y0 SBC SHRYPIXEL ; Subtract y0
BPL :S1 ; Skip if +ve BPL :S1 ; Skip if +ve
EOR #$FF ; Negate if -ve EOR #$FF ; Negate if -ve
INC A INC A
:S1 STA SHRTMPWRD+0 ; abs(y1 - y0) :S1 STA TMPZP+0 ; abs(y1 - y0)
STZ SHRTMPWRD+1 ; Pad to 16 bit STZ TMPZP+1 ; Pad to 16 bit
PHP ; Disable interrupts PHP ; Disable interrupts
SEI SEI
CLC ; 65816 native mode CLC ; 65816 native mode
@ -442,7 +443,7 @@ SHRLINE LDA A2L ; y1
BPL :S2 ; Skip if +ve BPL :S2 ; Skip if +ve
EOR #$FFFF ; Negate if -ve EOR #$FFFF ; Negate if -ve
INC A INC A
:S2 CMP SHRTMPWRD ; Cmp abs(x1 - x0) w/ abs(y1 - y0) :S2 CMP TMPZP ; Cmp abs(x1 - x0) w/ abs(y1 - y0)
BCC :YDOM ; abs(x1 - x0) < abs(y1 - y0) BCC :YDOM ; abs(x1 - x0) < abs(y1 - y0)
:XDOM LDA SHRXPIXEL ; x0 :XDOM LDA SHRXPIXEL ; x0
@ -462,17 +463,18 @@ SHRLINE LDA A2L ; y1
* Swap (x0, y0) and (x1, y1) * Swap (x0, y0) and (x1, y1)
* Called in 16 bit 65816 native mode * Called in 16 bit 65816 native mode
* Uses TMPZP+0,+1
SHRLINESWAP LDA SHRXPIXEL ; x0 SHRLINESWAP LDA SHRXPIXEL ; x0
STA SHRTMPWRD STA TMPZP
LDA A1L ; x1 LDA A1L ; x1
STA SHRXPIXEL STA SHRXPIXEL
LDA SHRTMPWRD LDA TMPZP
STA A1L STA A1L
LDA SHRYPIXEL ; y0 LDA SHRYPIXEL ; y0
STA SHRTMPWRD STA TMPZP
LDA A2L ; y1 LDA A2L ; y1
STA SHRYPIXEL STA SHRYPIXEL
LDA SHRTMPWRD LDA TMPZP
STA A2L STA A2L
RTS RTS
@ -544,11 +546,12 @@ SHRLINELO MX %00 ; Tell merlin 16 bit M & X
MX %11 ; Tell Merlin MX %11 ; Tell Merlin
PLP ; Resume normal service PLP ; Resume normal service
RTS RTS
:DX DW $0000 ; dx initially, then (2 * (dy - dx)) * Zero page
:DY DW $0000 ; dy initially, then (2 * dy) :DX EQU TMPZP+0 ; dx initially, then (2 * (dy - dx))
:YI DW $0000 ; +1 or -1 :DY EQU TMPZP+2 ; dy initially, then (2 * dy)
:D DW $0000 ; D :YI EQU TMPZP+4 ; +1 or -1
:LIM DW $0000 ; x1 gets stashed here :D EQU TMPZP+6 ; D
:LIM EQU TMPZP+8 ; x1 gets stashed here
* Plot y-dominant line (steep gradient) * Plot y-dominant line (steep gradient)
@ -620,12 +623,13 @@ SHRLINEHI MX %00 ; Tell Merlin 16 bit M & X
MX %11 ; Tell Merlin MX %11 ; Tell Merlin
PLP ; Resume normal service PLP ; Resume normal service
RTS RTS
:X DW $0000 * Zero page
:DX DW $0000 ; dx initially, then (2 * dx) :X EQU TMPZP+0
:DY DW $0000 ; dy initially, then (2 * (dy - dx))) :DX EQU TMPZP+2 ; dx initially, then (2 * dx)
:XI DW $0000 ; +1 or -1 :DY EQU TMPZP+4 ; dy initially, then (2 * (dy - dx)))
:D DW $0000 ; D :XI EQU TMPZP+6 ; +1 or -1
:LIM DW $0000 ; x1 gets stashed here :D EQU TMPZP+8 ; D
:LIM EQU TMPZP+10 ; x1 gets stashed here
* Convert high-resolution screen coordinates * Convert high-resolution screen coordinates