menu progress (text engine)

This commit is contained in:
ikari 2009-10-19 01:17:43 +02:00
parent ed22950f47
commit 85f2be9001
10 changed files with 4411 additions and 2341 deletions

View File

@ -1,4 +1,4 @@
OBJS = header.ips reset.o65 main.o65 font.o65 palette.o65 data.o65 const.o65 logo.o65 # gfx.o65 # vars.o65
OBJS = header.ips reset.o65 main.o65 font.o65 palette.o65 data.o65 const.o65 logo.o65 text.o65 # gfx.o65 # vars.o65
all: menu.bin

View File

@ -1,3 +1,76 @@
zero .word 0
hello .byt "Hello World!"
bg2tile .byt $20
zero .word 0
bg2tile .byt $20
hdma_pal .byt 44
.byt $60, $2d
.byt 24
.byt $00, $00
.byt 2
.byt $60, $2d
.byt 10
.byt $00, $00
.byt 10
.byt $20, $04
.byt 10
.byt $40, $08
.byt 10
.byt $60, $0c
.byt 10
.byt $80, $10
.byt 10
.byt $a0, $14
.byt 10
.byt $c0, $18
.byt 10
.byt $e0, $1c
.byt 10
.byt $00, $21
.byt 10
.byt $20, $25
.byt 10
.byt $40, $29
.byt 32
.byt $60, $2d
.byt 2
.byt $20, $04
.byt 1
.byt $60, $2d
.byt $00
hdma_cg_addr .byt $f0
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $f0
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00
hdma_mode .byt 74, $03, $01, $05, $00
hdma_scroll .byt 74
.byt $00, $00, $ff, $00
.byt $01
.byt $fc, $00, $05, $00
.byt $00
hello .byt "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ultrices pharetra libero et ultricies. Proin massa arcu, mattis eu gravida in, tempor sed magna. Mauris molestie purus urna, ut venenatis lorem. Nam nunc lorem, lacinia vel porta quis, sodales eleifend turpis. Aliquam nunc elit, consequat in malesuada vel, elementum eget ipsum. Duis eu lectus nec ipsum imperdiet adipiscing a ac nulla. Mauris risus nisi, posuere nec mollis ac, blandit quis lacus. Donec a sapien felis, ut tempus quam. Nunc semper erat et ipsum accumsan in condimentum enim adipiscing. Sed lobortis accumsan venenatis. Donec euismod mauris gravida risus convallis commodo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis vehicula sem sit amet arcu luctus rhoncus. Etiam sed vulputate ligula. Etiam mauris lectus, eleifend nec fermentum id, bibendum sit amet purus. Pellentesque sollicitudin turpis in leo pharetra vulputate. Sed consequat mattis tortor vitae consectetur. Nullam quis ante in nisl venenatis dignissim. Duis mattis lacus euismod leo volutpat. ", 0

View File

@ -1,3 +1,28 @@
.data
testvar .byt 0
testvar2 .word 0
;don't anger the stack!
;padding is necessary because snescom wouldn't heed *=$7E0200.
stack .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;----------parameters for text output----------
print_x .byt 0 ;x coordinate
.byt 0
print_y .byt 0 ;y coordinate
.byt 0
print_src .word 0 ;source data address
print_bank .byt 0 ;source data bank
print_pal .byt 0 ;palette number for text output

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@ IRQ_16bit:
rep #$30
pha: phx: phy: phd: phb
jsl @IRQ_ROUTINE
rep #$30
bra int_exit
;error vectors

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,113 @@
#include "memmap.i65"
GAME_MAIN:
jsr snes_init
jsr font_dma
jsr setup_gfx
jsr tests
- wai
bra -
jsr setup_hdma
- bra -
font_dma:
setup_hdma:
sep #$20 : .as
rep #$10 : .xl
stz $420b
stz $420c
lda #$02 ;A to B; direct; 2x single reg
sta $4320 ;we use ch. 2 for color data
lda #$22 ;2122 = CG RAM
sta $4321 ;dest: CG RAM
lda #^hdma_pal
ldy #!hdma_pal
sty $4322
sta $4324
lda #$00 ;A to B; direct; 1x single reg
sta $4310 ;ch. 1 for color address
lda #$21 ;2121 = CG addr
sta $4311 ;dest: CG Address
lda #^hdma_cg_addr
ldy #!hdma_cg_addr
sty $4312
sta $4314
lda #$00 ;A to B; direct; 1x single reg
sta $4330 ;ch. 3 for mode switch
lda #$05 ;2105 = BG mode
sta $4331
lda #^hdma_mode
ldy #!hdma_mode
sty $4332
sta $4334
lda #$03 ;A to B; direct; 2x 2x single reg
sta $4340 ;ch. 4 for scroll
lda #$0d ;210e = BG1VOFS
sta $4341
lda #^hdma_scroll
ldy #!hdma_scroll
sty $4342
sta $4344
; lda #$06
; sta $420c ;enable HDMA ch. 1+2
lda #$80
sta $4200 ;enable V-BLANK NMI
rts
setup_gfx:
sep #$20 : .as
rep #$10 : .xl
stz $420b
stz $420c
;clear tilemap buffers
lda #$08 ;A to B; fixed, one reg
sta $4300
lda #^zero
ldy #!zero
sty $4302
sta $4304
ldx #$0 ;65536
stx $4305
ldx #$0000
stx $2181
lda #$01
sta $2183
lda #$80
sta $4301
lda #$01
sta $420b
lda #$01 ;A to B; (direct); non-fixed, inc, two reg
sta $4300 ;to DMA ch.0 ctrl
lda #^font ;font source bank
ldy #!font ;font source address
lda #^font2 ;font source bank
ldy #!font2 ;font source address
sty $4302 ;address -> 4302,4303
sta $4304 ;bank -> 4304
ldx #$1000 ;transfer size
ldx #$2000 ;transfer size
stx $4305 ;to reg
stz $2116 ;VRAM address 0
stz $2117 ;
ldx #$4000 ;BG2 chr
stx $2116 ;VRAM address 0x8000
lda #$18 ;VRAM data port
sta $4301 ;to channel 0 tgt address
lda #$01 ;ch 0 enable
sta $420b ;GPDMA GO!
lda #$01 ;A to B; (direct); non-fixed, inc, two reg
sta $4300 ;to DMA ch.0 ctrl
lda #^font4 ;font source bank
ldy #!font4 ;font source address
sty $4302 ;address -> 4302,4303
sta $4304 ;bank -> 4304
ldx #$4000 ;transfer size
stx $4305 ;to reg
ldx #$0000 ;BG1 chr
stx $2116 ;VRAM address 0x0000
lda #$18 ;VRAM data port
sta $4301 ;to channel 0 tgt address
lda #$01 ;ch 0 enable
sta $420b ;GPDMA GO!
lda #$09 ;A to B; fixed, two reg
sta $4300
lda #^zero
@ -33,8 +116,8 @@ font_dma:
sta $4304
ldx #$1000
stx $4305 ;zero 4096b of VRAM
ldx #$3000
stx $2116 ;from 0x6000-0x6fff
ldx #$5000
stx $2116 ;from 0xa000-0xafff
lda #$18 ;VRAM data port
sta $4301 ;to channel 0 tgt address
lda #$01
@ -47,10 +130,10 @@ font_dma:
ldy #!logo ;font source address
sty $4302 ;address -> 4302,4303
sta $4304 ;bank -> 4304
ldx #$4b00 ;transfer size
ldx #$3480 ;transfer size
stx $4305 ;to reg
ldx #$800 ;after font
stx $2116 ;VRAM address 0x1000
ldx #$2000 ;after font
stx $2116 ;VRAM address 0x4000
lda #$18 ;VRAM data port
sta $4301 ;to channel 0 tgt address
lda #$01 ;ch 0 enable
@ -59,54 +142,18 @@ font_dma:
; copy logo tilemap
lda #$01 ;A to B; (direct); non-fixed, inc, two reg
sta $4300 ;to DMA ch.0 ctrl
lda #^logomap ;font source bank
ldy #!logomap ;font source address
lda #^logomap ;font source bank
ldy #!logomap ;font source address
sty $4302 ;address -> 4302,4303
sta $4304 ;bank -> 4304
ldx #$300 ;transfer size
ldx #$280 ;transfer size
stx $4305 ;to reg
ldx #$3400 ;BG1 tilemap
ldx #$5400 ;BG1 tilemap
stx $2116 ;VRAM address 0x6800
lda #$18 ;VRAM data port
sta $4301 ;to channel 0 tgt address
lda #$01 ;ch 0 enable
sta $420b ;GPDMA GO!
;copy test text
lda #$00 ;A->B, inc, 1 reg
sta $4300
lda #^hello
ldy #!hello
sty $4302
sta $4304
ldx #$c ;24 bytes
stx $4305
ldx #$3020
stx $2116
lda #$18
sta $4301
stz $2115 ;increment after LOW byte (write to 2118)
lda #$01
sta $420b
lda #$08 ;A->B, fixed, 1 reg
sta $4300
lda #^bg2tile
ldy #!bg2tile
sty $4302
sta $4304
ldx #$c ;24 bytes
stx $4305
ldx #$3020
stx $2116
lda #$19
sta $4301
lda #$80
sta $2115 ;increment after HIGH byte (write to 2119)
lda #$01
sta $420b
stz $2121 ;palette index 0
lda #$00
sta $4300
@ -123,15 +170,18 @@ font_dma:
rts
tests:
sep #$30 : .as : .xs ;8-bit accumulator and index
sep #$20 : .as ;8-bit accumulator
rep #$10 : .xl ;16-bit index
lda #$0f
sta $2100 ;screen on, full brightness
lda #$04 ;mode 4, mode 5 is a bitch :(
lda #$03 ;mode 3, mode 5 via HDMA :D
sta $2105
lda #$34 ;Tilemap addr 0x6800
lda #$54 ;Tilemap addr 0xA800
sta $2107 ;for BG1
lda #$30 ;Tilemap addr 0x6000
lda #$50 ;Tilemap addr 0xA000
sta $2108 ;for BG2
lda #$40 ;chr base addr:
sta $210b ;BG1=0x0000, BG2=0x8000
lda #$03 ;enable BG1+BG2
sta $212c ;BG Main
sta $212d ;BG Sub
@ -143,20 +193,21 @@ tests:
lda #$0
ldx #$0
ldy #$0
- bra -
-
inx
bne +
iny
+
stz $2121
stx $2122
sty $2122
bra -
lda #$44
sta @AVR_CMD
lda #0
sta print_x
lda #10
sta print_y
lda #^hello
ldx #!hello
sta print_bank
stx print_src
jsr print
rts
snes_init:
sep #$20 : .as ;8-bit accumulator
sep #$20 : .as ;8-bit accumulator
lda #$01
sta $420d ; FAAAAAST
lda #$8f
@ -170,7 +221,7 @@ snes_init:
stz $2106 ;
stz $2107 ;
stz $2108 ;
stz $2109 ;
stz $2109 ;
stz $210a ;
stz $210b ;
stz $210c ;
@ -180,7 +231,7 @@ snes_init:
stz $210e ;
stz $210f ;
stz $210f ;
lda #$00
lda #$05
sta $2110 ;
stz $2110 ;
stz $2111 ;
@ -202,7 +253,7 @@ snes_init:
lda #$01
sta $211b ;
stz $211c ;
stz $211c ;
stz $211c ;
stz $211d ;
stz $211d ;
stz $211e ;
@ -247,3 +298,73 @@ snes_init:
stz $420c ;
rts
texttest:
rep #$10 : .xl
sep #$20 : .as
;copy test text
lda #$00 ;A->B, inc, 1 reg
sta $4300
lda #^hello
ldy #!hello
sty $4302
sta $4304
ldx #31 ;26 bytes
stx $4305
ldx #$5140
stx $2116
lda #$18
sta $4301
stz $2115 ;increment after LOW byte (write to 2118)
lda #$01
sta $420b
lda #$08 ;A->B, fixed, 1 reg
sta $4300
lda #^bg2tile
ldy #!bg2tile
sty $4302
sta $4304
ldx #31 ;26 bytes
stx $4305
ldx #$5140
stx $2116
lda #$19
sta $4301
lda #$80
sta $2115 ;increment after HIGH byte (write to 2119)
lda #$01
sta $420b
lda #$00 ;A->B, inc, 1 reg
sta $4300
lda #^hello
ldy #!hello+4
sty $4302
sta $4304
ldx #$c ;24 bytes
stx $4305
ldx #$5540
stx $2116
lda #$18
sta $4301
stz $2115 ;increment after LOW byte (write to 2118)
lda #$01
sta $420b
lda #$08 ;A->B, fixed, 1 reg
sta $4300
lda #^bg2tile
ldy #!bg2tile
sty $4302
sta $4304
ldx #$c ;24 bytes
stx $4305
ldx #$5540
stx $2116
lda #$19
sta $4301
lda #$80
sta $2115 ;increment after HIGH byte (write to 2119)
lda #$01
sta $420b
rts

View File

@ -1,5 +1,4 @@
palette .byt $00, $00, $ff, $7f, $00, $00, $18, $63
.byt $60, $2d, $df, $6b, $70, $05, $7f, $4f
palette .byt $42, $08, $ff, $7f, $00, $00, $18, $63
.byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42
@ -9,56 +8,57 @@ palette .byt $00, $00, $ff, $7f, $00, $00, $18, $63
.byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $83, $52, $ae, $77, $8e, $73, $c5, $5a
.byt $ce, $7b, $81, $10, $a1, $14, $c1, $18
.byt $61, $0c, $41, $08, $23, $25, $6b, $6f
.byt $ad, $77, $63, $2d, $66, $4e, $27, $46
.byt $49, $6b, $e6, $3d, $e3, $41, $c6, $72
.byt $04, $4e, $05, $7f, $a6, $66, $e5, $7a
.byt $86, $62, $05, $46, $26, $52, $e6, $76
.byt $26, $4e, $87, $5e, $65, $5a, $06, $7f
.byt $67, $5a, $a7, $6a, $c2, $41, $a2, $2d
.byt $c4, $41, $24, $5a, $05, $52, $26, $56
.byt $a2, $3d, $4a, $2d, $6c, $31, $dc, $1c
.byt $bf, $14, $35, $29, $9f, $14, $37, $29
.byt $7f, $10, $31, $29, $6a, $2d, $17, $25
.byt $67, $2d, $2f, $25, $11, $21, $11, $25
.byt $4a, $29, $bc, $18, $31, $25, $bf, $18
.byt $65, $31, $6c, $2d, $6d, $2d, $8b, $31
.byt $51, $29, $fb, $20, $c4, $39, $68, $2e
.byt $e4, $2d, $a1, $31, $81, $2d, $0d, $2b
.byt $2e, $27, $eb, $26, $67, $2a, $c4, $29
.byt $61, $29, $ec, $2a, $6f, $23, $6f, $27
.byt $4e, $27, $0c, $27, $a9, $26, $06, $2a
.byt $cb, $2e, $69, $2e, $e5, $2d, $06, $32
.byt $28, $36, $ac, $26, $c4, $31, $28, $32
.byt $67, $19, $c6, $6e, $c3, $3d, $4f, $29
.byt $f4, $20, $f8, $20, $45, $29, $53, $29
.byt $bd, $18, $88, $31, $18, $21, $9f, $10
.byt $73, $2d, $d1, $18, $d9, $1c, $fa, $1c
.byt $a3, $29, $82, $29, $41, $25, $89, $26
.byt $23, $1d, $0e, $27, $6b, $22, $87, $19
.byt $2e, $23, $c9, $1d, $cd, $21, $f6, $1e
.byt $ac, $22, $30, $22, $ff, $17, $8a, $15
.byt $ff, $1b, $5a, $1f, $ac, $19, $b4, $1e
.byt $7b, $1f, $28, $15, $cd, $19, $71, $1e
.byt $b5, $1e, $d5, $1a, $73, $1e, $ee, $1d
.byt $8b, $19, $e6, $10, $39, $1f, $31, $22
.byt $28, $19, $df, $1b, $93, $1a, $9c, $1f
.byt $ca, $18, $d7, $1c, $ce, $18, $aa, $14
.byt $88, $10, $b8, $18, $cc, $18, $9b, $14
.byt $c8, $18, $a6, $14, $81, $14, $01, $1d
.byt $f7, $1e, $0f, $1e, $18, $23, $ff, $13
.byt $48, $15, $8a, $1d, $9c, $1b, $bd, $1b
.byt $30, $1e, $48, $19, $a1, $18, $a1, $10
.byt $61, $10, $c3, $39, $c8, $5a, $2a, $67
.byt $6c, $6f, $c6, $5a, $4b, $6b, $29, $67
.byt $e7, $5e, $a5, $56, $e1, $3d, $64, $4e
.byt $c1, $39, $a6, $56, $a1, $35, $65, $4e
.byt $61, $2d, $81, $31, $01, $42, $e3, $3d
.byt $85, $52, $08, $63, $e8, $5e, $25, $46
.byt $8d, $73, $09, $63, $84, $52, $03, $42
.byt $63, $4e, $23, $46, $62, $4e, $22, $46
.byt $41, $29, $21, $25, $04, $42, $a8, $56
.byt $87, $52, $e4, $3d, $0a, $63, $21, $46
.byt $a4, $56, $01, $21, $e1, $1c, $a3, $35
.byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $03, $21, $64, $2d, $62, $0c
.byt $e2, $20, $44, $29, $85, $31, $c5, $3d
.byt $8c, $73, $47, $4a, $23, $25, $84, $31
.byt $e7, $3d, $e5, $41, $65, $5a, $c6, $3d
.byt $a6, $62, $06, $7f, $04, $4a, $08, $7b
.byt $e3, $45, $83, $39, $c6, $6e, $24, $52
.byt $e4, $7a, $e6, $76, $45, $52, $c7, $72
.byt $e4, $49, $23, $4e, $86, $5e, $68, $4e
.byt $a2, $31, $c5, $35, $85, $62, $c5, $2d
.byt $87, $5e, $a4, $2d, $c4, $3d, $a5, $6a
.byt $47, $5a, $07, $4a, $4d, $29, $16, $29
.byt $a7, $35, $36, $25, $be, $18, $1a, $21
.byt $83, $2d, $18, $21, $50, $31, $fb, $20
.byt $4a, $2d, $2e, $29, $dc, $1c, $31, $29
.byt $6a, $2d, $de, $1c, $aa, $31, $87, $31
.byt $53, $2d, $e6, $41, $40, $46, $aa, $32
.byt $28, $2e, $2f, $2b, $4f, $27, $0e, $27
.byt $cb, $2a, $68, $2a, $e4, $2d, $83, $29
.byt $61, $29, $0d, $2f, $4f, $2b, $ec, $2a
.byt $ab, $2a, $cc, $2e, $68, $2e, $4e, $2b
.byt $8a, $2e, $ad, $26, $a4, $31, $0d, $2b
.byt $26, $19, $4e, $27, $ef, $2a, $47, $19
.byt $c4, $14, $c2, $39, $c3, $49, $c2, $45
.byt $46, $56, $65, $2d, $f8, $20, $4c, $29
.byt $2f, $29, $19, $29, $51, $29, $c9, $18
.byt $da, $18, $a8, $18, $9c, $18, $d1, $18
.byt $84, $10, $db, $18, $7e, $14, $f1, $1c
.byt $eb, $20, $a2, $18, $48, $2a, $20, $25
.byt $e3, $20, $ee, $26, $4a, $22, $e5, $18
.byt $ef, $21, $50, $1e, $48, $19, $e5, $14
.byt $58, $1f, $ff, $17, $bd, $1f, $ab, $1d
.byt $f7, $1e, $cc, $19, $ff, $1f, $d5, $1e
.byt $c4, $10, $7a, $1f, $6a, $19, $ef, $19
.byt $72, $1e, $94, $1a, $93, $1e, $ce, $1d
.byt $49, $15, $9c, $1f, $b3, $1e, $94, $1e
.byt $bd, $17, $18, $1f, $de, $1f, $8b, $19
.byt $71, $22, $49, $19, $d4, $18, $ce, $18
.byt $88, $10, $b6, $18, $b1, $18, $a6, $14
.byt $c4, $5a, $e2, $5e, $d4, $1e, $06, $15
.byt $ed, $1d, $38, $1f, $ce, $19, $27, $19
.byt $a0, $39, $a9, $56, $0b, $63, $45, $4a
.byt $2a, $63, $c8, $56, $88, $52, $6b, $6f
.byt $6e, $6f, $4d, $6b, $ae, $77, $24, $46
.byt $09, $5f, $23, $46, $4a, $6b, $e9, $5a
.byt $e1, $41, $c3, $3d, $e4, $41, $82, $35
.byt $64, $4a, $a7, $52, $86, $4e, $2c, $63
.byt $a4, $52, $ca, $5a, $65, $4e, $43, $29
.byt $62, $2d, $8d, $73, $8f, $6f, $66, $4e
.byt $c8, $5a, $42, $46, $21, $25, $29, $67
.byt $42, $4a, $c6, $56, $e2, $1c, $02, $21
.byt $07, $63, $a2, $14, $eb, $5e, $c1, $18
.byt $82, $10, $e7, $5a, $cf, $7b, $82, $4e

View File

@ -12,7 +12,40 @@
; NMI - called once per screen refresh (or something like that)
NMI_ROUTINE:
sep #$20 : .as
lda $4210
lda @$4210
lda #$01
sta $4300
lda #^BG1_TILE_BUF
ldx #!BG1_TILE_BUF+64*10
stx $4302
sta $4304
ldx #$380*2-64*10
stx $4305
ldx #BG1_TILE_BASE+32*10
stx $2116
lda #$18
sta $4301
lda #$01
sta $420b
lda #$01
sta $4300
lda #^BG2_TILE_BUF
ldx #!BG2_TILE_BUF+64*10
stx $4302
sta $4304
ldx #$380*2-64*10
stx $4305
ldx #BG2_TILE_BASE+32*10
stx $2116
lda #$18
sta $4301
lda #$01
sta $420b
lda #$1e ; ch. 1-4
sta @$420c ; trigger HDMA
rtl
; IRQ - called when triggered (which is..?)
@ -21,112 +54,3 @@ IRQ_ROUTINE:
lda $4211 ;Acknowledge irq
rtl
; To be called regularly - updated screen contents
; Sends the palette structure to PPU
PaletteDMA:
.xl : .as
lda #$00 : sta $4300 ;dma type
lda #$22 : sta $4301 ;address $2122
lda #^(PALETTE_ADDRESS) : sta $4304
ldx #!(PALETTE_ADDRESS) : stx $4302
ldx #512 : stx $4305 ; size: 16*2*16 bytes.
lda #$00 : sta $2121 ;Write CGRAM address (0)
lda #$01 : sta $420B ;Activate dma 0
rts
; Sends the video buffer contents to PPU
VRAMdma:
sty $2116 ;Write VRAM address
sty $4302 : sta $4304 ;Write DMA address
stx $4305 ;Write size
lda #$80 : sta $2115 ;PPU programming
lda #$01 : sta $4300 ;dma type
lda #$18 : sta $4301 ;address $2118
lda #$01 : sta $420B ;Activate DMA 0
rts
; Jumped to from snesheader.a65 - when the game is reseted.
RESET_GAME:
rep #$30 : .al : .xl
lda #$0400 : tcd
ldx #$03FE : txs
sep #$20 : .as
pha
plb
lda #$01
sta $420D ; set "fast" mode
; Next initialize screen
jsr InitializeScreen
jsr InitializeIRQ
sep #$20 : .as
;lda #$17
lda #$03
sta $212C ; put screens on
sta $212D ; put screens on
lda #$00: sta $2121
lda #$E0: sta $2122
lda #$7C: sta $2122
jmp @GAME_MAIN
InitializeIRQ:
sep #$20 : .as
lda #$B1 : sta $4200
ldx #0 : stx $4207
ldx #211 : stx $4209
sei
lda $4211
- lda $4210 ;: bpl -
rts
InitializeScreen:
rep #$10 : .xl
sep #$20 : .as
lda #$00 : sta $2101
ldx #$0000 : stx $2102
lda #$09 : sta $2105 ; select screen mode 1.
lda #$00 : sta $2106
lda #TILE_ADDR_REG_VAL(BG1_TILE_ADDR, 0) : sta $2107
lda #TILE_ADDR_REG_VAL(BG2_TILE_ADDR, 0) : sta $2108
lda #TILE_ADDR_REG_VAL(BG3_TILE_ADDR, 0) : sta $2109
lda #TILE_ADDR_REG_VAL(BG4_TILE_ADDR, 0) : sta $210A
lda #BMAP_ADDR_REG_VAL(BG1_BMAP_ADDR, BG2_BMAP_ADDR) : sta $210B
lda #BMAP_ADDR_REG_VAL(BG3_BMAP_ADDR, BG4_BMAP_ADDR) : sta $210C
; Set scrolling to 0,0 to all bgs
lda #$00 : sta $210D : sta $210D
lda #$00 : sta $210E : sta $210E
lda #$00 : sta $210F : sta $210F
lda #$00 : sta $2110 : sta $2110
lda #$00 : sta $2111 : sta $2111
lda #$00 : sta $2112 : sta $2112
lda #$00 : sta $2113 : sta $2113
lda #$00 : sta $2114 : sta $2114
rts

101
snes/text.a65 Normal file
View File

@ -0,0 +1,101 @@
.text
#include "memmap.i65"
print:
rep #$30 : .xl : .al
lda !print_x
and #$00ff
lsr
bcs print_bg1
ldx #!BG1_TILE_BUF ; for 2nd loop
phx
ldx #!BG2_TILE_BUF ; for 1st loop
phx
bra print_bg_cont
print_bg1
ldx #!BG2_TILE_BUF+1 ; for 2nd loop
phx
ldx #!BG1_TILE_BUF ; for 1st loop da whoop
phx
bra print_bg_cont
print_bg_cont
sta !print_x
lda !print_y
and #$00ff
asl
asl
asl
asl
asl
clc
adc !print_x
asl ; double the offset for WRAM addressing
tay ; zonday
plx
phy ; offset from tilemap start
stx !print_x
clc
adc !print_x
; we need to transfer to WRAM and from there to VRAM via DMA during VBLANK
; because VRAM can only be accessed during VBLANK and forced blanking.
sta $2181
sep #$20 : .as
lda #$7f ;we really only need the lsb. full bank for clarity
sta $2183
print_loop
ldx !print_src
lda !print_bank
pha
plb
phx ; source addr
print_loop_inner
lda !0,x
asl
sta @$2180
lda #$00
adc #$00
sta @$2180
inx
lda !0,x
beq print_loop2
inx
lda !0,x
beq print_loop2
bra print_loop_inner
print_loop2
lda #$00
pha
plb
rep #$30 : .al : .xl
ply ; source addr
iny
pla ; offset from tilemap start
plx ; other tilemap addr
stx !print_x
clc
adc print_x ; tilemap+offset
sta $2181
tyx
sep #$20 : .as
lda print_bank
pha
plb
print_loop2_inner
lda !0,x
asl
sta @$2180
lda #$00
adc #$00
sta @$2180
inx
lda !0,x
beq print_end
inx
lda !0,x
beq print_end
bra print_loop2_inner
print_end
lda #$00
pha
plb
rts