mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-09-10 08:54:51 +00:00
Merge branch 'master' of git://github.com/deater/dos33fsprogs
This commit is contained in:
commit
78a5b0e76e
@ -595,3 +595,68 @@ int basic_vlin(int y1, int y2, int at) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
short gr_addr_lookup[48]={
|
||||
0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780,
|
||||
0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8,
|
||||
0x450,0x4d0,0x550,0x5d0,0x650,0x6d0,0x750,0x7d0,
|
||||
};
|
||||
|
||||
int grsim_put_sprite(unsigned char *sprite_data, int xpos, int ypos) {
|
||||
|
||||
unsigned char i;
|
||||
unsigned char *ptr;
|
||||
short address;
|
||||
|
||||
ptr=sprite_data;
|
||||
x=*ptr;
|
||||
ptr++;
|
||||
ram[CV]=*ptr;
|
||||
ptr++;
|
||||
|
||||
while(1) {
|
||||
address=gr_addr_lookup[ypos/2];
|
||||
address+=xpos;
|
||||
for(i=0;i<x;i++) {
|
||||
a=*ptr;
|
||||
if (a==0) {
|
||||
}
|
||||
else if ((a&0xf0)==0) {
|
||||
ram[address]&=0xf0;
|
||||
ram[address]|=a;
|
||||
}
|
||||
else if ((a&0x0f)==0) {
|
||||
ram[address]&=0x0f;
|
||||
ram[address]|=a;
|
||||
}
|
||||
else {
|
||||
ram[address]=a;
|
||||
}
|
||||
ptr++;
|
||||
address++;
|
||||
}
|
||||
ypos++;
|
||||
ram[CV]--;
|
||||
if (ram[CV]==0) break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gr_copy(short source, short dest) {
|
||||
|
||||
short dest_addr,source_addr;
|
||||
int i,j;
|
||||
|
||||
for(i=0;i<8;i++) {
|
||||
source_addr=gr_addr_lookup[i]+0x400;
|
||||
dest_addr=gr_addr_lookup[i];
|
||||
|
||||
for(j=0;j<120;j++) {
|
||||
ram[dest_addr+j]=ram[source_addr+j];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,4 +11,5 @@ int bload(char *filename, int address);
|
||||
int scrn(unsigned char xcoord, unsigned char ycoord);
|
||||
int grsim_unrle(unsigned char *rle_data, int address);
|
||||
int home(void);
|
||||
|
||||
int grsim_put_sprite(unsigned char *sprite_data, int xpos, int ypos);
|
||||
int gr_copy(short source, short dest);
|
||||
|
24
gr-sim/tfv.c
24
gr-sim/tfv.c
@ -32,23 +32,45 @@ static unsigned char title_rle[]=
|
||||
|
||||
};
|
||||
|
||||
static unsigned char test_sprite[]={
|
||||
0x8,0x4,
|
||||
0x55,0x50,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00,
|
||||
0xff,0x1f,0x4f,0x2f,0xff,0x22,0x20,0x00,
|
||||
0x5f,0x5f,0x5f,0x5f,0xff,0xf2,0xf2,0xf2,
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int ch;
|
||||
int x,y;
|
||||
|
||||
grsim_init();
|
||||
|
||||
/* Title Screen */
|
||||
grsim_unrle(title_rle,0x400);
|
||||
grsim_unrle(title_rle,0x800);
|
||||
gr_copy(0x800,0x400);
|
||||
|
||||
grsim_update();
|
||||
|
||||
x=20; y=21;
|
||||
color_equals(0);
|
||||
|
||||
while(1) {
|
||||
|
||||
ch=grsim_input();
|
||||
|
||||
if (ch=='q') break;
|
||||
if (ch=='i') if (y>0) y-=2;
|
||||
if (ch=='m') if (y<39) y+=2;
|
||||
if (ch=='j') if (x>0) x--;
|
||||
if (ch=='k') if (x<39) x++;
|
||||
|
||||
gr_copy(0x800,0x400);
|
||||
grsim_put_sprite(test_sprite,x,y);
|
||||
|
||||
grsim_update();
|
||||
|
||||
usleep(100000);
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ PNG2GR = ../gr-utils/png2gr
|
||||
all: tfv.dsk
|
||||
|
||||
tfv.dsk: TITLE.GR TFV ED
|
||||
$(DOS33) -y tfv.dsk BSAVE -a 0xc00 TFV
|
||||
$(DOS33) -y tfv.dsk BSAVE -a 0x1000 TFV
|
||||
$(DOS33) -y tfv.dsk BSAVE -a 0x400 TITLE.GR
|
||||
$(DOS33) -y tfv.dsk BSAVE -a 0x900 ED
|
||||
|
||||
TFV: tfv.o
|
||||
ld65 -o TFV tfv.o -C ./apple2_c00.inc
|
||||
ld65 -o TFV tfv.o -C ./apple2_1000.inc
|
||||
|
||||
tfv.o: tfv.s title.inc
|
||||
ca65 -o tfv.o tfv.s -l tfv.lst
|
||||
@ -27,3 +27,4 @@ TITLE.GR: title.png
|
||||
|
||||
clean:
|
||||
rm -f *~ TITLE.GR *.o *.lst ED
|
||||
|
||||
|
12
tfv/apple2_1000.inc
Normal file
12
tfv/apple2_1000.inc
Normal file
@ -0,0 +1,12 @@
|
||||
MEMORY {
|
||||
ZP: start = $00, size = $1A, type = rw;
|
||||
RAM: start = $1000, size = $8E00, file = %O;
|
||||
}
|
||||
|
||||
SEGMENTS {
|
||||
CODE: load = RAM, type = ro;
|
||||
RODATA: load = RAM, type = ro;
|
||||
DATA: load = RAM, type = rw;
|
||||
BSS: load = RAM, type = bss, define = yes;
|
||||
ZEROPAGE: load = ZP, type = zp;
|
||||
}
|
BIN
tfv/tfv.dsk
BIN
tfv/tfv.dsk
Binary file not shown.
361
tfv/tfv.s
361
tfv/tfv.s
@ -1,14 +1,22 @@
|
||||
.define EQU =
|
||||
|
||||
KEYPRESS EQU $C000
|
||||
KEYRESET EQU $C010
|
||||
|
||||
;; SOFT SWITCHES
|
||||
GR EQU $C050
|
||||
TEXT EQU $C051
|
||||
FULLGR EQU $C052
|
||||
TEXTGR EQU $C053
|
||||
PAGE0 EQU $C054
|
||||
PAGE1 EQU $C055
|
||||
LORES EQU $C056
|
||||
HIRES EQU $C057
|
||||
GR EQU $C050
|
||||
TEXT EQU $C051
|
||||
FULLGR EQU $C052
|
||||
TEXTGR EQU $C053
|
||||
PAGE0 EQU $C054
|
||||
PAGE1 EQU $C055
|
||||
LORES EQU $C056
|
||||
HIRES EQU $C057
|
||||
|
||||
PADDLE_BUTTON0 EQU $C061
|
||||
PADDL0 EQU $C064
|
||||
PTRIG EQU $C070
|
||||
|
||||
|
||||
;; MONITOR ROUTINES
|
||||
HLINE EQU $F819 ;; HLINE Y,$2C at A
|
||||
@ -38,11 +46,20 @@ H2 EQU $2C
|
||||
V2 EQU $2D
|
||||
MASK EQU $2E
|
||||
COLOR EQU $30
|
||||
FIRST EQU $F0
|
||||
|
||||
TEMP EQU $FA
|
||||
RUN EQU $FA
|
||||
TEMP2 EQU $FB
|
||||
FIRST EQU $F0
|
||||
LASTKEY EQU $F1
|
||||
PADDLE_STATUS EQU $F2
|
||||
XPOS EQU $F3
|
||||
YPOS EQU $F4
|
||||
TEMP EQU $FA
|
||||
RUN EQU $FA
|
||||
TEMP2 EQU $FB
|
||||
TEMPY EQU $FB
|
||||
INL EQU $FC
|
||||
INH EQU $FD
|
||||
OUTL EQU $FE
|
||||
OUTH EQU $FF
|
||||
|
||||
;=============================
|
||||
; set low-res graphics, page 0
|
||||
@ -55,6 +72,10 @@ TEMP2 EQU $FB
|
||||
;=================
|
||||
jsr CLRTOP
|
||||
|
||||
lda #$c
|
||||
sta BASH
|
||||
lda #$0
|
||||
sta BASL ; load image off-screen 0xc00
|
||||
|
||||
lda #>(title_image)
|
||||
sta GBASH
|
||||
@ -62,14 +83,71 @@ TEMP2 EQU $FB
|
||||
sta GBASL
|
||||
jsr load_rle_gr
|
||||
|
||||
jsr gr_copy
|
||||
|
||||
lda #20
|
||||
sta YPOS
|
||||
lda #20
|
||||
sta XPOS
|
||||
|
||||
main_loop:
|
||||
|
||||
jsr gr_copy
|
||||
|
||||
jsr put_sprite
|
||||
|
||||
jsr wait_until_keypressed
|
||||
|
||||
lda LASTKEY
|
||||
|
||||
cmp #('Q')
|
||||
beq exit
|
||||
|
||||
cmp #('I')
|
||||
bne check_down
|
||||
dec YPOS
|
||||
dec YPOS
|
||||
|
||||
check_down:
|
||||
cmp #('M')
|
||||
bne check_left
|
||||
inc YPOS
|
||||
inc YPOS
|
||||
|
||||
check_left:
|
||||
cmp #('J')
|
||||
bne check_right
|
||||
dec XPOS
|
||||
|
||||
check_right:
|
||||
cmp #('K')
|
||||
bne check_done
|
||||
inc XPOS
|
||||
|
||||
check_done:
|
||||
jmp main_loop
|
||||
|
||||
|
||||
|
||||
exit:
|
||||
|
||||
lda #$4
|
||||
sta BASH
|
||||
lda #$0
|
||||
sta BASL ; 0x400 is GR page 0
|
||||
sta BASL ; restore to 0x400 (page 0)
|
||||
; copy to 0x400 (page 0)
|
||||
|
||||
; call home
|
||||
jsr HOME
|
||||
|
||||
|
||||
; Return to BASIC?
|
||||
rts
|
||||
|
||||
;=====================================================================
|
||||
;= ROUTINES
|
||||
;=====================================================================
|
||||
|
||||
;=================
|
||||
; load RLE image
|
||||
;=================
|
||||
@ -188,4 +266,261 @@ set_gr_page0:
|
||||
bit GR ; set graphics
|
||||
rts
|
||||
|
||||
;=========================================================
|
||||
; gr_copy
|
||||
;=========================================================
|
||||
; for now copy 0xc00 to 0x400
|
||||
; 2 + 8*38 + 4*80*23 + 4*120*26 + 13 = 20,159 = 20ms = 50Hz
|
||||
;
|
||||
gr_copy:
|
||||
ldx #0 ; set y to zero ; 2
|
||||
|
||||
gr_copy_loop:
|
||||
stx TEMP ; save y ; 3
|
||||
txa ; move to A ; 2
|
||||
asl ; mult by 2 ; 2
|
||||
tay ; put into Y ; 2
|
||||
lda gr_offsets,Y ; lookup low byte for line addr ; 5
|
||||
sta OUTL ; out and in are the same ; 3
|
||||
sta INL ; 3
|
||||
lda gr_offsets+1,Y ; lookup high byte for line addr ; 5
|
||||
sta OUTH ; 3
|
||||
adc #$8 ; for now, fixed 0xc ; 2
|
||||
sta INH ; 3
|
||||
ldx TEMP ; restore y ; 3
|
||||
|
||||
ldy #0 ; set X counter to 0 ; 2
|
||||
gr_copy_line:
|
||||
lda (INL),Y ; load a byte ; 5
|
||||
sta (OUTL),Y ; store a byte ; 6
|
||||
iny ; increment pointer ; 2
|
||||
|
||||
cpx #$4 ; don't want to copy bottom 4*40 ; 2
|
||||
bcs gr_copy_above4 ; 3
|
||||
|
||||
gr_copy_below4:
|
||||
cpy #120 ; for early ones, copy 120 bytes ; 2
|
||||
bne gr_copy_line ; 3
|
||||
beq gr_copy_line_done ; 3
|
||||
|
||||
gr_copy_above4: ; for last four, just copy 80 bytes
|
||||
cpy #80 ; 2
|
||||
bne gr_copy_line ; 3
|
||||
|
||||
gr_copy_line_done:
|
||||
inx ; increment y value ; 2
|
||||
cpx #8 ; there are 8 of them ; 2
|
||||
bne gr_copy_loop ; if not, loop ; 3
|
||||
rts ; 6
|
||||
|
||||
;==========================================================
|
||||
; Wait until keypressed
|
||||
;==========================================================
|
||||
;
|
||||
|
||||
wait_until_keypressed:
|
||||
lda KEYPRESS ; check if keypressed
|
||||
bpl wait_until_keypressed ; if not, loop
|
||||
jmp figure_out_key
|
||||
|
||||
|
||||
;==========================================================
|
||||
; Get Key
|
||||
;==========================================================
|
||||
;
|
||||
|
||||
get_key:
|
||||
|
||||
check_paddle_button:
|
||||
|
||||
; check for paddle button
|
||||
|
||||
bit PADDLE_BUTTON0
|
||||
bpl no_button
|
||||
lda #' '+128
|
||||
jmp save_key
|
||||
|
||||
no_button:
|
||||
lda KEYPRESS
|
||||
bpl no_key
|
||||
|
||||
figure_out_key:
|
||||
cmp #' '+128 ; the mask destroys space
|
||||
beq save_key ; so handle it specially
|
||||
|
||||
and #$5f ; mask, to make upper-case
|
||||
check_right_arrow:
|
||||
cmp #$15
|
||||
bne check_left_arrow
|
||||
lda #'K'
|
||||
check_left_arrow:
|
||||
cmp #$08
|
||||
bne check_up_arrow
|
||||
lda #'J'
|
||||
check_up_arrow:
|
||||
cmp #$0B
|
||||
bne check_down_arrow
|
||||
lda #'I'
|
||||
check_down_arrow:
|
||||
cmp #$0A
|
||||
bne check_escape
|
||||
lda #'M'
|
||||
check_escape:
|
||||
cmp #$1B
|
||||
bne save_key
|
||||
lda #'Q'
|
||||
jmp save_key
|
||||
|
||||
no_key:
|
||||
bit PADDLE_STATUS
|
||||
bpl no_key_store
|
||||
|
||||
; check for paddle action
|
||||
; code from http://web.pdx.edu/~heiss/technotes/aiie/tn.aiie.06.html
|
||||
|
||||
inc PADDLE_STATUS
|
||||
lda PADDLE_STATUS
|
||||
and #$03
|
||||
beq check_paddles
|
||||
jmp no_key_store
|
||||
|
||||
check_paddles:
|
||||
lda PADDLE_STATUS
|
||||
and #$80
|
||||
sta PADDLE_STATUS
|
||||
|
||||
ldx #$0
|
||||
LDA PTRIG ;TRIGGER PADDLES
|
||||
LDY #0 ;INIT COUNTER
|
||||
NOP ;COMPENSATE FOR 1ST COUNT
|
||||
NOP
|
||||
PREAD2: LDA PADDL0,X ;COUNT EVERY 11 uSEC.
|
||||
BPL RTS2D ;BRANCH WHEN TIMED OUT
|
||||
INY ;INCREMENT COUNTER
|
||||
BNE PREAD2 ;CONTINUE COUNTING
|
||||
DEY ;COUNTER OVERFLOWED
|
||||
RTS2D: ;RETURN W/VALUE 0-255
|
||||
|
||||
cpy #96
|
||||
bmi paddle_left
|
||||
cpy #160
|
||||
bmi no_key_store
|
||||
lda #'K'
|
||||
jmp save_key
|
||||
paddle_left:
|
||||
lda #'J'
|
||||
jmp save_key
|
||||
|
||||
no_key_store:
|
||||
lda #0 ; no key, so save a zero
|
||||
|
||||
save_key:
|
||||
sta LASTKEY ; save the key to our buffer
|
||||
bit KEYRESET ; clear the keyboard buffer
|
||||
rts
|
||||
|
||||
;=============================================
|
||||
; put_sprite
|
||||
;=============================================
|
||||
put_sprite:
|
||||
|
||||
lda #>tb1_sprite ; hardcoded for tb1 for now
|
||||
sta INH
|
||||
lda #<tb1_sprite
|
||||
sta INL
|
||||
|
||||
ldy #0 ; byte 0 is xsize
|
||||
lda (INL),Y
|
||||
sta CH
|
||||
iny
|
||||
|
||||
lda (INL),Y ; byte 1 is ysize
|
||||
sta CV
|
||||
iny
|
||||
|
||||
lda YPOS ; make a copy of ypos
|
||||
sta TEMPY ; as we modify it
|
||||
|
||||
put_sprite_loop:
|
||||
sty TEMP ; save sprite pointer
|
||||
|
||||
ldy TEMPY
|
||||
lda gr_offsets,Y ; lookup low-res memory address ; 5
|
||||
clc
|
||||
adc XPOS ; add in xpos
|
||||
sta OUTL ; store out low byte of addy ; 3
|
||||
lda gr_offsets+1,Y ; look up high byte ; 5
|
||||
sta OUTH ; and store it out ; 3
|
||||
ldy TEMP ; restore sprite pointer ; 3
|
||||
|
||||
ldx CH
|
||||
|
||||
put_sprite_pixel:
|
||||
lda (INL),Y ; get sprite colors
|
||||
iny ; increment sprite pointer
|
||||
|
||||
sty TEMP ; save sprite pointer
|
||||
ldy #$0
|
||||
|
||||
cmp #$0 ; if all zero, transparent
|
||||
beq put_sprite_done_draw ; don't draw it
|
||||
|
||||
sta COLOR ; save color for later
|
||||
and #$f0 ; check if top nibble zero
|
||||
bne put_sprite_bottom ; if not skip ahead
|
||||
|
||||
lda #$0f ; setup mask
|
||||
sta MASK
|
||||
bmi put_sprite_mask
|
||||
|
||||
put_sprite_bottom:
|
||||
lda COLOR ; re-load color
|
||||
and #$0f ; check if bottom nibble zero
|
||||
bne put_sprite_all ; if not, skip ahead
|
||||
lda #$0f
|
||||
sta MASK ; setup mask
|
||||
|
||||
put_sprite_mask:
|
||||
lda (OUTL),Y ; get color at output
|
||||
and MASK ; mask off unneeded part
|
||||
ora COLOR ; or the color in
|
||||
sta (OUTL),Y ; store it back
|
||||
|
||||
jmp put_sprite_done_draw ; we are done
|
||||
|
||||
put_sprite_all:
|
||||
lda COLOR ; load color
|
||||
sta (OUTL),Y ; and write it out
|
||||
|
||||
|
||||
put_sprite_done_draw:
|
||||
|
||||
ldy TEMP ; restore sprite pointer
|
||||
|
||||
inc OUTL ; increment output pointer
|
||||
dex ; decrement x counter
|
||||
bne put_sprite_pixel ; if not done, keep looping
|
||||
|
||||
inc TEMPY ; each line has two y vars
|
||||
inc TEMPY
|
||||
dec CV ; decemenet total y count
|
||||
bne put_sprite_loop ; loop if not done
|
||||
|
||||
rts ; return
|
||||
|
||||
|
||||
; waste memory with a lookup table
|
||||
; maybe faster than using GBASCALC?
|
||||
gr_offsets:
|
||||
.word $400,$480,$500,$580,$600,$680,$700,$780
|
||||
.word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8
|
||||
.word $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0
|
||||
|
||||
tb1_sprite:
|
||||
.byte $8,$4
|
||||
.byte $55,$50,$00,$00,$00,$00,$00,$00
|
||||
.byte $55,$55,$55,$00,$00,$00,$00,$00
|
||||
.byte $ff,$1f,$4f,$2f,$ff,$22,$20,$00
|
||||
.byte $5f,$5f,$5f,$5f,$ff,$f2,$f2,$f2
|
||||
|
||||
.include "title.inc"
|
||||
|
Loading…
Reference in New Issue
Block a user