forked from brooke/mandel-6502
WIP input handling for coords
experimental output via 32-bits mult, looses precision in conversion
This commit is contained in:
parent
fab2760394
commit
96e0356e57
1 changed files with 128 additions and 8 deletions
136
mandel.s
136
mandel.s
|
|
@ -126,6 +126,10 @@ KEY_7 = 51
|
|||
KEY_8 = 53
|
||||
KEY_9 = 48
|
||||
KEY_0 = 50
|
||||
KEY_PERIOD = 34
|
||||
KEY_E = 42
|
||||
KEY_X = 22
|
||||
KEY_Y = 43
|
||||
|
||||
.struct float48
|
||||
exponent .byte
|
||||
|
|
@ -257,6 +261,28 @@ fixed3_13_as_float: ; float48
|
|||
.byte $00
|
||||
.byte $00
|
||||
|
||||
u65536_as_float: ; float48
|
||||
; 1 << 16
|
||||
; 65536
|
||||
; 06 55 36 . 00 00
|
||||
.byte 66 ; exponent/sign - +2 bytes
|
||||
.byte $06
|
||||
.byte $55
|
||||
.byte $36
|
||||
.byte $00
|
||||
.byte $00
|
||||
|
||||
fixed6_26_as_float: ; float48
|
||||
; 1 << 26
|
||||
; 67108864
|
||||
; 67 10 88 64 . 00
|
||||
.byte 67 ; exponent/sign - +3 bytes
|
||||
.byte $67
|
||||
.byte $10
|
||||
.byte $88
|
||||
.byte $64
|
||||
.byte $00
|
||||
|
||||
sec_per_frame: ; float48 00 . 01 66 66 66 67
|
||||
.byte 63 ; exponent/sign - -1 bytes
|
||||
.byte $01 ; BCD digits
|
||||
|
|
@ -403,6 +429,13 @@ elapsed_work:
|
|||
elapsed_digit:
|
||||
.byte 0
|
||||
|
||||
input_col:
|
||||
.byte 0
|
||||
input_row:
|
||||
.byte 0
|
||||
input_max:
|
||||
.byte 0
|
||||
|
||||
; 2 + 9 * byte cycles
|
||||
.macro add bytes, dest, arg1, arg2
|
||||
clc ; 2 cyc
|
||||
|
|
@ -983,6 +1016,66 @@ common:
|
|||
|
||||
.endproc
|
||||
|
||||
; input in FR0, 32 bits signed 6.26 fixed
|
||||
; output in FR0, Atari float
|
||||
; clobbers a, x, y, FR0, FR1
|
||||
.proc fixed6_26_to_float
|
||||
; check sign bit! conversion routine is for unsigned
|
||||
lda FR0 + 3
|
||||
and #$80
|
||||
sta temp
|
||||
|
||||
beq positive
|
||||
neg32 FR0
|
||||
positive:
|
||||
|
||||
; save low word
|
||||
lda FR0
|
||||
pha
|
||||
lda FR0 + 1
|
||||
pha
|
||||
|
||||
; convert high word
|
||||
sta FR0 + 2
|
||||
sta FR1
|
||||
lda FR0 + 3
|
||||
sta FR0 + 1
|
||||
jsr IFP
|
||||
|
||||
lda temp
|
||||
beq positive2
|
||||
; set float sign bit
|
||||
lda FR0
|
||||
ora #$80
|
||||
sta FR0
|
||||
positive2:
|
||||
|
||||
; high word to FR1
|
||||
ldx #.lobyte(u65536_as_float)
|
||||
ldy #.hibyte(u65536_as_float)
|
||||
jsr FLD1R
|
||||
jsr FMUL
|
||||
jsr FMOVE
|
||||
|
||||
; convert low word
|
||||
pla
|
||||
lda temp + 1
|
||||
pla
|
||||
lda temp
|
||||
jsr IFP
|
||||
|
||||
; combine
|
||||
jsr FADD
|
||||
|
||||
; scale
|
||||
ldx #.lobyte(fixed6_26_as_float)
|
||||
ldy #.hibyte(fixed6_26_as_float)
|
||||
jsr FLD1R
|
||||
jsr FDIV
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
; input in FR0, Atari float
|
||||
; output in FR0, 16 bits signed 3.13 fixed
|
||||
; clobbers a, x, y, FR0, FR1
|
||||
|
|
@ -1603,7 +1696,7 @@ number_keys:
|
|||
beq five
|
||||
cpy #KEY_6
|
||||
beq six
|
||||
jmp skip_char
|
||||
jmp letter_keys
|
||||
|
||||
one:
|
||||
ldx #0
|
||||
|
|
@ -1622,7 +1715,21 @@ five:
|
|||
jmp load_key_viewport
|
||||
six:
|
||||
ldx #5
|
||||
; fall through
|
||||
jmp load_key_viewport
|
||||
|
||||
letter_keys:
|
||||
cpy #KEY_X
|
||||
bne not_x
|
||||
jsr input_x
|
||||
jmp load_key_viewport
|
||||
not_x:
|
||||
cpy #KEY_Y
|
||||
bne not_y
|
||||
jsr input_y
|
||||
jmp load_key_viewport
|
||||
not_y:
|
||||
jmp skip_char
|
||||
|
||||
load_key_viewport:
|
||||
jsr load_viewport
|
||||
; fall through
|
||||
|
|
@ -1632,6 +1739,23 @@ done:
|
|||
|
||||
.endproc
|
||||
|
||||
.proc input_x
|
||||
ldx #col_x
|
||||
ldy #1
|
||||
jsr input_number
|
||||
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
.proc input_y
|
||||
rts
|
||||
.endproc
|
||||
|
||||
.proc input_number
|
||||
rts
|
||||
.endproc
|
||||
|
||||
.proc clear_screen
|
||||
; zero the range from framebuffer_top to display_list
|
||||
lda #.lobyte(framebuffer_top)
|
||||
|
|
@ -1679,9 +1803,7 @@ zero_byte_loop:
|
|||
draw_string_const str_x
|
||||
|
||||
copy32 FR0, ox
|
||||
shift_round_16 FR0, 3
|
||||
copy16 FR0, FR0 + 2
|
||||
jsr fixed3_13_to_float
|
||||
jsr fixed6_26_to_float
|
||||
jsr FASC
|
||||
jsr draw_string
|
||||
|
||||
|
|
@ -1690,9 +1812,7 @@ zero_byte_loop:
|
|||
draw_string_const str_y
|
||||
|
||||
copy32 FR0, oy
|
||||
shift_round_16 FR0, 3
|
||||
copy16 FR0, FR0 + 2
|
||||
jsr fixed3_13_to_float
|
||||
jsr fixed6_26_to_float
|
||||
jsr FASC
|
||||
jsr draw_string
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue