1/2/3 selectable viewports

This commit is contained in:
Brooke Vibber 2024-12-30 09:16:08 -08:00
parent e51aa91e4e
commit 100c0f3314
2 changed files with 49 additions and 18 deletions

View file

@ -104,6 +104,9 @@ KEY_UP = $8e
KEY_DOWN = $8f
KEY_LEFT = $86
KEY_RIGHT = $87
KEY_1 = $1f
KEY_2 = $1e
KEY_3 = $1a
.struct float48
exponent .byte
@ -250,14 +253,17 @@ fill_masks:
viewport_zoom:
.byte 1
.byte 6
.byte 8
viewport_ox:
.word $0000
.word $f110
.word $f110
viewport_oy:
.word $0000
.word $fb60
.word $fbe0
; 2 + 9 * byte cycles
@ -1206,7 +1212,13 @@ done:
beq left
cpy #KEY_RIGHT
beq right
cpy #KEY_1
beq one
cpy #KEY_2
beq two
cpy #KEY_3
beq three
skip_char:
lda #0
rts
@ -1234,6 +1246,19 @@ left:
jmp done
right:
add16 ox, ox, temp
jmp done
one:
ldx #0
jmp load_key_viewport
two:
ldx #1
jmp load_key_viewport
three:
ldx #2
; fall through
load_key_viewport:
jsr load_viewport
; fall through
done:
lda #255
rts
@ -1271,13 +1296,10 @@ zero_byte_loop:
rts
.endproc
.proc start
; input: viewport selector in x
; clobbers: a, x
.proc load_viewport
jsr imul8xe_init
; initialize viewport
ldx #0 ; overview
;ldx #1 ; closeup
lda viewport_zoom,x
sta zoom
@ -1294,16 +1316,16 @@ zero_byte_loop:
lda viewport_oy,x
sta oy + 1
; count_frames = 0; count_pixels = 0
lda #0
sta count_frames
sta count_pixels
rts
.endproc
; total_ms = 0.0; total_pixels = 0.0
ldx #total_ms
jsr ZF1
ldx #total_pixels
jsr ZF1
.proc start
jsr imul8xe_init
; initialize viewport
ldx #0 ; overview
jsr load_viewport
; Disable display DMA
lda #0
@ -1345,6 +1367,17 @@ copy_byte_loop:
jsr SETVBV
main_loop:
; count_frames = 0; count_pixels = 0
lda #0
sta count_frames
sta count_pixels
; total_ms = 0.0; total_pixels = 0.0
ldx #total_ms
jsr ZF1
ldx #total_pixels
jsr ZF1
jsr clear_screen
jsr status_bar

View file

@ -1,7 +1,5 @@
things to try:
* add some preset viewports that can be switched via number keys (1, 2, 3 etc)
* patch the entire expanded-ram imul8xe on top of imul8 to avoid the 3-cycle thunk penalty :D
* optimize out a store/load with mul8_add16 and mul8_add24