mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-08-12 19:25:16 +00:00
tfv: update flying code some more
This commit is contained in:
@@ -240,10 +240,10 @@ void draw_background_mode7(void) {
|
|||||||
|
|
||||||
fixed_mul(&space_z,&BETA,&factor);
|
fixed_mul(&space_z,&BETA,&factor);
|
||||||
|
|
||||||
printf("spacez=%lf beta=%lf factor=%lf\n",
|
// printf("spacez=%lf beta=%lf factor=%lf\n",
|
||||||
fixed_to_double(&space_z),
|
// fixed_to_double(&space_z),
|
||||||
fixed_to_double(&BETA),
|
// fixed_to_double(&BETA),
|
||||||
fixed_to_double(&factor));
|
// fixed_to_double(&factor));
|
||||||
|
|
||||||
for (screen_y = 8; screen_y < LOWRES_H; screen_y+=2) {
|
for (screen_y = 8; screen_y < LOWRES_H; screen_y+=2) {
|
||||||
|
|
||||||
|
163
tfv/tfv_flying.s
163
tfv/tfv_flying.s
@@ -2,6 +2,8 @@ SHIPY EQU $E4
|
|||||||
|
|
||||||
; FIXME, sort out available ZP page space
|
; FIXME, sort out available ZP page space
|
||||||
TURNING EQU $40
|
TURNING EQU $40
|
||||||
|
SCREEN_X EQU $41
|
||||||
|
SCREEN_Y EQU $42
|
||||||
|
|
||||||
|
|
||||||
SHIPX EQU 15
|
SHIPX EQU 15
|
||||||
@@ -122,18 +124,16 @@ draw_background_mode7:
|
|||||||
|
|
||||||
; Draw Sky
|
; Draw Sky
|
||||||
|
|
||||||
lda #COLOR_BOTH_MEDIUMBLUE
|
lda #COLOR_BOTH_MEDIUMBLUE ; MEDIUMBLUE color
|
||||||
sta COLOR
|
sta COLOR
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
sky_loop:
|
sky_loop: ; draw line across screen
|
||||||
ldy #40
|
ldy #40 ; from y=0 to y=6
|
||||||
sty V2
|
sty V2
|
||||||
ldy #0
|
ldy #0
|
||||||
pha
|
pha
|
||||||
|
jsr hlin_double ; hlin y,V2 at A
|
||||||
jsr hlin_double
|
|
||||||
|
|
||||||
pla
|
pla
|
||||||
clc
|
clc
|
||||||
adc #2
|
adc #2
|
||||||
@@ -142,43 +142,146 @@ sky_loop:
|
|||||||
|
|
||||||
; Draw Horizon
|
; Draw Horizon
|
||||||
|
|
||||||
lda #COLOR_BOTH_GREY
|
lda #COLOR_BOTH_GREY ; Horizon is Grey
|
||||||
sta COLOR
|
sta COLOR
|
||||||
|
lda #6 ; draw single line at 6/7
|
||||||
lda #6
|
|
||||||
ldy #40
|
ldy #40
|
||||||
sty V2
|
sty V2 ; hlin Y,V2 at A
|
||||||
jsr hlin_double
|
ldy #0
|
||||||
|
jsr hlin_double ; hlin 0,40 at 6
|
||||||
|
|
||||||
; Temporarily Draw Ocean Everywhere
|
; Temporarily Draw Ocean Everywhere
|
||||||
|
|
||||||
lda #COLOR_BOTH_DARKBLUE
|
lda #8
|
||||||
sta COLOR
|
sta SCREEN_Y
|
||||||
|
|
||||||
lda #6
|
screeny_loop:
|
||||||
sea_loop:
|
|
||||||
ldy #40
|
|
||||||
sty V2
|
|
||||||
ldy #0
|
ldy #0
|
||||||
pha
|
jsr hlin_setup
|
||||||
|
|
||||||
jsr hlin_double
|
|
||||||
|
|
||||||
pla
|
lda #0
|
||||||
|
sta SCREEN_X
|
||||||
|
screenx_loop:
|
||||||
|
|
||||||
|
jsr lookup_map ; get color in A
|
||||||
|
ldy #0
|
||||||
|
sta (GBASL),Y
|
||||||
|
inc GBASL
|
||||||
|
|
||||||
|
inc SCREEN_X
|
||||||
|
lda SCREEN_X
|
||||||
|
cmp #40 ; LOWRES width
|
||||||
|
bne screenx_loop
|
||||||
|
|
||||||
|
|
||||||
|
lda SCREEN_Y
|
||||||
clc
|
clc
|
||||||
adc #2
|
adc #2
|
||||||
cmp #40
|
sta SCREEN_Y
|
||||||
bne sea_loop
|
cmp #40 ; LOWRES height
|
||||||
|
bne screeny_loop
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;====================
|
||||||
|
; lookup_map
|
||||||
|
;====================
|
||||||
|
; finds value in space_x.i,space_y.i
|
||||||
|
; returns color in A
|
||||||
|
lookup_map:
|
||||||
|
lda #COLOR_BOTH_DARKBLUE ; the color of the sea
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
flying_map:
|
flying_map:
|
||||||
.byte 2,15,15,15, 15,15,15, 2
|
.byte $22,$ff,$ff,$ff, $ff,$ff,$ff,$22
|
||||||
.byte 13,12,12, 8, 4, 4, 0,13
|
.byte $dd,$cc,$cc,$88, $44,$44,$00,$dd
|
||||||
.byte 13,12,12,12, 8, 4, 4,13
|
.byte $dd,$cc,$cc,$cc, $88,$44,$44,$dd
|
||||||
.byte 13,12,12, 8, 4, 4, 4,13
|
.byte $dd,$cc,$cc,$88, $44,$44,$44,$dd
|
||||||
.byte 13,12, 9, 9, 8, 4, 4,13
|
.byte $dd,$cc,$99,$99, $88,$44,$44,$dd
|
||||||
.byte 13,12, 9, 8, 4, 4, 4,13
|
.byte $dd,$cc,$99,$88, $44,$44,$44,$dd
|
||||||
.byte 13,12, 9, 9, 1, 4, 4,13
|
.byte $dd,$cc,$99,$99, $11,$44,$44,$dd
|
||||||
.byte 2,13,13,13, 13,13,13, 2
|
.byte $22,$dd,$dd,$dd, $dd,$dd,$dd,$22
|
||||||
|
|
||||||
|
|
||||||
|
; http://www.llx.com/~nparker/a2/mult.html
|
||||||
|
; MULTIPLY NUM1H:NUM1L * NUM2H:NUM2L
|
||||||
|
|
||||||
|
NUM1: .byte 0,0
|
||||||
|
NUM2: .byte 0,0
|
||||||
|
RESULT: .byte 0,0,0,0
|
||||||
|
|
||||||
|
multiply:
|
||||||
|
lda #0 ; Initialize RESULT to 0
|
||||||
|
sta RESULT+2
|
||||||
|
ldx #16 ; There are 16 bits in NUM2
|
||||||
|
L1:
|
||||||
|
lsr NUM2+1 ; Get low bit of NUM2
|
||||||
|
ror NUM2
|
||||||
|
bcc L2 ; 0 or 1?
|
||||||
|
tay ; If 1, add NUM1 (hi byte of RESULT is in A)
|
||||||
|
clc
|
||||||
|
lda NUM1
|
||||||
|
adc RESULT+2
|
||||||
|
sta RESULT+2
|
||||||
|
tya
|
||||||
|
adc NUM1+1
|
||||||
|
L2:
|
||||||
|
ror A ; "Stairstep" shift
|
||||||
|
ror RESULT+2
|
||||||
|
ror RESULT+1
|
||||||
|
ror RESULT
|
||||||
|
dex
|
||||||
|
bne L1
|
||||||
|
sta RESULT+3
|
||||||
|
rts
|
||||||
|
|
||||||
|
; 8.8 fixed point
|
||||||
|
fixed_sin:
|
||||||
|
.byte $00,$00 ; 0.000000=00.00
|
||||||
|
.byte $00,$61 ; 0.382683=00.61
|
||||||
|
.byte $00,$b5 ; 0.707107=00.b5
|
||||||
|
.byte $00,$ec ; 0.923880=00.ec
|
||||||
|
.byte $01,$00 ; 1.000000=01.00
|
||||||
|
.byte $00,$ec ; 0.923880=00.ec
|
||||||
|
.byte $00,$b5 ; 0.707107=00.b5
|
||||||
|
.byte $00,$61 ; 0.382683=00.61
|
||||||
|
.byte $00,$00 ; 0.000000=00.00
|
||||||
|
.byte $ff,$9f ; -0.382683=ff.9f
|
||||||
|
.byte $ff,$4b ; -0.707107=ff.4b
|
||||||
|
.byte $ff,$14 ; -0.923880=ff.14
|
||||||
|
.byte $ff,$00 ; -1.000000=ff.00
|
||||||
|
.byte $ff,$14 ; -0.923880=ff.14
|
||||||
|
.byte $ff,$4b ; -0.707107=ff.4b
|
||||||
|
.byte $ff,$9f ; -0.382683=ff.9f
|
||||||
|
|
||||||
|
fixed_sin_scale:
|
||||||
|
.byte $00,$00
|
||||||
|
.byte $00,$0c
|
||||||
|
.byte $00,$16
|
||||||
|
.byte $00,$1d
|
||||||
|
.byte $00,$20
|
||||||
|
.byte $00,$1d
|
||||||
|
.byte $00,$16
|
||||||
|
.byte $00,$0c
|
||||||
|
.byte $00,$00
|
||||||
|
.byte $ff,$f4
|
||||||
|
.byte $ff,$ea
|
||||||
|
.byte $ff,$e3
|
||||||
|
.byte $ff,$e0
|
||||||
|
.byte $ff,$e3
|
||||||
|
.byte $ff,$ea
|
||||||
|
.byte $ff,$f4
|
||||||
|
|
||||||
|
horizontal_lookup:
|
||||||
|
.byte $0C,$0A,$09,$08,$07,$06,$05,$05,$04,$04,$04,$04,$03,$03,$03,$03
|
||||||
|
.byte $26,$20,$1B,$18,$15,$13,$11,$10,$0E,$0D,$0C,$0C,$0B,$0A,$0A,$09
|
||||||
|
.byte $40,$35,$2D,$28,$23,$20,$1D,$1A,$18,$16,$15,$14,$12,$11,$10,$10
|
||||||
|
.byte $59,$4A,$40,$38,$31,$2C,$28,$25,$22,$20,$1D,$1C,$1A,$18,$17,$16
|
||||||
|
.byte $73,$60,$52,$48,$40,$39,$34,$30,$2C,$29,$26,$24,$21,$20,$1E,$1C
|
||||||
|
.byte $8C,$75,$64,$58,$4E,$46,$40,$3A,$36,$32,$2E,$2C,$29,$27,$25,$23
|
||||||
|
.byte $A6,$8A,$76,$68,$5C,$53,$4B,$45,$40,$3B,$37,$34,$30,$2E,$2B,$29
|
||||||
|
@@ -477,19 +477,12 @@ vlin_too_slow:
|
|||||||
rts ; return
|
rts ; return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;================================
|
;================================
|
||||||
; hlin_double:
|
; hlin_setup
|
||||||
;================================
|
;================================
|
||||||
; VLIN Y, V2 AT A
|
; put address in GBASL/GBASH
|
||||||
; Y, X, A trashed
|
; Ycoord in A, X coord inY
|
||||||
hlin_double:
|
hlin_setup:
|
||||||
;int hlin_double(int page, int x1, int x2, int at) {
|
|
||||||
|
|
||||||
sty TEMPY
|
sty TEMPY
|
||||||
tay ; y=A
|
tay ; y=A
|
||||||
lda gr_offsets,Y ; lookup low-res memory address
|
lda gr_offsets,Y ; lookup low-res memory address
|
||||||
@@ -501,6 +494,20 @@ hlin_double:
|
|||||||
lda gr_offsets,Y
|
lda gr_offsets,Y
|
||||||
adc DRAW_PAGE ; add in draw page offset
|
adc DRAW_PAGE ; add in draw page offset
|
||||||
sta GBASH
|
sta GBASH
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;================================
|
||||||
|
; hlin_double:
|
||||||
|
;================================
|
||||||
|
; HLIN Y, V2 AT A
|
||||||
|
; Y, X, A trashed
|
||||||
|
hlin_double:
|
||||||
|
;int hlin_double(int page, int x1, int x2, int at) {
|
||||||
|
|
||||||
|
jsr hlin_setup
|
||||||
|
|
||||||
sec
|
sec
|
||||||
lda V2
|
lda V2
|
||||||
@@ -527,7 +534,7 @@ hlin_loop:
|
|||||||
inc GBASL
|
inc GBASL
|
||||||
dex
|
dex
|
||||||
bne hlin_loop
|
bne hlin_loop
|
||||||
|
return:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user