second status bar display with coords/zoom

currently using 3.13 precision to output to floats for formatting
This commit is contained in:
Brooke Vibber 2025-02-22 11:23:13 -08:00
parent 26d612b6f3
commit 07db3d00d7

162
mandel.s
View file

@ -169,6 +169,27 @@ str_padding_len = str_padding_end - str_padding
speed_start = 40 - str_done_len - str_speed_len - str_padding_len - 1 speed_start = 40 - str_done_len - str_speed_len - str_padding_len - 1
col_x = 1
str_x:
.byte "X:"
.byte 0
str_x_len = 2
str_x_space = 12
str_x_padding = 2
col_y = str_x_len + str_x_space + str_x_padding
str_y:
.byte "Y:"
.byte 0
str_y_len = 2
str_y_space = 12
str_y_padding = 2
col_zoom = col_y + str_y_len + str_y_space + str_y_padding
str_zoom:
.byte "ZOOM:"
.byte 0
str_zoom_len = 5
char_map: char_map:
; Map ATASCII string values to framebuffer font entries ; Map ATASCII string values to framebuffer font entries
@ -205,6 +226,17 @@ aspect_x: ; fixed3.13 5/4
aspect_y: ; fixed3.13 3/4 aspect_y: ; fixed3.13 3/4
.word 3 << (13 - 2) .word 3 << (13 - 2)
fixed3_13_as_float: ; float48
; 1 << 13
; 8192
; 81 92 . 00 00 00
.byte 65 ; exponent/sign - +1 byte
.byte $81
.byte $92
.byte $00
.byte $00
.byte $00
sec_per_frame: ; float48 00 . 01 66 66 66 67 sec_per_frame: ; float48 00 . 01 66 66 66 67
.byte 63 ; exponent/sign - -1 bytes .byte 63 ; exponent/sign - -1 bytes
.byte $01 ; BCD digits .byte $01 ; BCD digits
@ -895,6 +927,68 @@ next:
.endmacro .endmacro
; input in FR0, 16 bits signed 3.13 fixed
; output in FR0, Atari float
; clobbers a, x, y, FR0, FR1
.proc fixed3_13_to_float
ldx #.lobyte(fixed3_13_as_float)
ldy #.hibyte(fixed3_13_as_float)
jsr FLD1R
; check sign bit! conversion routine is for unsigned
lda FR0 + 1
bpl positive
negative:
neg16 FR0
jsr IFP
; set float sign bit
lda FR0
ora #$80
sta FR0
jmp common
positive:
jsr IFP
common:
jsr FDIV
rts
.endproc
; input in FR0, Atari float
; output in FR0, 16 bits signed 3.13 fixed
; clobbers a, x, y, FR0, FR1
.proc float_to_fixed3_13
ldx #.lobyte(fixed3_13_as_float)
ldy #.hibyte(fixed3_13_as_float)
jsr FLD1R
jsr FMUL
; check sign bit! conversion routine is for unsigned
lda FR0
bcc positive
negative:
; clearfloat sign bit
lda FR0
eor #$80
sta FR0
jsr FPI
neg16 FR0
jmp common
positive:
jsr FPI
common:
rts
.endproc
.proc mandelbrot .proc mandelbrot
; input: ; input:
; cx: position scaled to 6.26 fixed point - -32..+31.9 ; cx: position scaled to 6.26 fixed point - -32..+31.9
@ -1254,7 +1348,7 @@ done:
.endproc .endproc
; in/out: column in text_col ; in/out: column in text_col
; in: row in text_row @fixme implement ; in: row in text_row
; in: pointer to string in INBUFF ; in: pointer to string in INBUFF
; clobbers x/y/a/temp ; clobbers x/y/a/temp
.proc draw_string .proc draw_string
@ -1269,6 +1363,21 @@ done:
adc #0 adc #0
sta temp + 1 sta temp + 1
ldx text_row
beq done_rows
continue_rows:
clc
lda temp
adc #40
sta temp
lda temp + 1
adc #0
sta temp + 1
dex
bne continue_rows
done_rows:
ldy #0 ldy #0
loop: loop:
lda (strptr),y lda (strptr),y
@ -1429,7 +1538,7 @@ skip_char:
plus: plus:
lda zoom lda zoom
cmp #7 cmp #8
bpl skip_char bpl skip_char
inc zoom inc zoom
jmp done jmp done
@ -1441,15 +1550,19 @@ minus:
jmp done jmp done
up: up:
sub32 oy, oy, temp sub32 oy, oy, temp
jsr display_coords
jmp done jmp done
down: down:
add32 oy, oy, temp add32 oy, oy, temp
jsr display_coords
jmp done jmp done
left: left:
sub32 ox, ox, temp sub32 ox, ox, temp
jsr display_coords
jmp done jmp done
right: right:
add32 ox, ox, temp add32 ox, ox, temp
jsr display_coords
jmp done jmp done
number_keys: number_keys:
@ -1533,6 +1646,49 @@ zero_byte_loop:
rts rts
.endproc .endproc
.proc display_coords
lda #1
sta text_row
lda #col_x
sta text_col
draw_string_const str_x
copy32 FR0, ox
shift_round_16 FR0, 3
copy16 FR0, FR0 + 2
jsr fixed3_13_to_float
jsr FASC
jsr draw_string
lda #col_y
sta text_col
draw_string_const str_y
copy32 FR0, oy
shift_round_16 FR0, 3
copy16 FR0, FR0 + 2
jsr fixed3_13_to_float
jsr FASC
jsr draw_string
lda #col_zoom
sta text_col
draw_string_const str_zoom
lda zoom
clc
adc #0
sta FR0
lda #0
sta FR0 + 1
jsr IFP
jsr FASC
jsr draw_string
rts
.endproc
; input: viewport selector in x ; input: viewport selector in x
; clobbers: a, x ; clobbers: a, x
.proc load_viewport .proc load_viewport
@ -1584,6 +1740,7 @@ zero_byte_loop:
sta DMACTL sta DMACTL
jsr clear_screen jsr clear_screen
jsr display_coords
; Copy the display list into properly aligned memory ; Copy the display list into properly aligned memory
; Can't cross 1024-byte boundaries :D ; Can't cross 1024-byte boundaries :D
@ -1639,6 +1796,7 @@ main_loop:
jsr clear_screen jsr clear_screen
jsr status_bar jsr status_bar
jsr display_coords
lda #0 lda #0
sta fill_level sta fill_level