/
graphics.asm
897 lines (816 loc) · 22.8 KB
/
graphics.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
INCLUDE "vendor/gbhw.inc"
PUSHS
SECTION "Shadow OAM",WRAM0[$C000]
shadowOAM:
DS 4*40
POPS
MAP_SIZE_16x16 EQU 4
MAP_SIZE_32x32 EQU 5
MAP_SIZE_64x64 EQU 6
MAP_SIZE_128x128 EQU 7
PUSHS
SECTION "Graphics WRAM",WRAM0
MapAddress: DS 2
CurrentCameraX: DS 2 ; What is currently displayed on the hardware right now?
CurrentCameraY: DS 2
TargetCameraX: DS 2 ; What do we WANT to be displayed on the hardware?
TargetCameraY: DS 2
CurrentTileX: DS 2
CurrentTileY: DS 2
OldTileX: DS 2
OldTileY: DS 2
FrameCounter: DS 2
SPRITE_CHUNK EQU 0
SPRITE_X_POS EQU 1
SPRITE_Y_POS EQU 3
SPRITE_TILE_BASE EQU 5
SPRITE_ANIMATION_START EQU 6
SPRITE_ANIMATION_CURRENT EQU 8
SPRITE_ANIMATION_DURATION EQU 10
SPRITE_ACTIVE EQU 11
SPRITE_HUD_SPACE EQU 12
SpriteList: DS 17*13 ; 17 total 16x16 sprites, 13 bytes per table entry
ANIMATION_DURATION EQU 0
ANIMATION_TILE_INDEX EQU 1
ANIMATION_X_OFFSET EQU 2
ANIMATION_Y_OFFSET EQU 3
; various temps
tPosX: DS 2
tPosY: DS 2
tDebugGraphics: DS 4
tDebugScrollX: DS 1
tDebugChunkLeft: DS 2
tDebugFinalX: DS 2
POPS
PUSHS
SECTION "Graphics Code",ROM0
_oamDMA:
ld a,$C0
ld [$FF46],a
ld a,$28
.wait:
dec a
jr nz,.wait
ret
_oamDMAEnd:
oamDMA:
call $FF80
ret
initOAM:
; copy OAM DMA routine into high RAM
ld hl,_oamDMA
ld de,$FF80
ld bc,(_oamDMAEnd - _oamDMA)
call mem_Copy
; clear out shadow OAM
ld d,40
ld hl,shadowOAM
.loop:
ld a,$FF ; Y-coordinate
ld [hl+],a
ld a,$FF ; X-coordinate
ld [hl+],a
ld a,$00 ; tile-index
ld [hl+],a
ld a,$00 ; attributes
ld [hl+],a
dec d
jr nz, .loop
ret
; ##########################################################################
; # 16x16 Sprites #
; ##########################################################################
; Note: These utility functions assume
; that the sprite mode is already 8x16
;***************************************************************************
;*
;* set_16x16_Tile - Sets an entire 16x16 sprite, assuming sequential tile
;* numbers, and sequential OAM table entries.
;*
;* arguments:
;* \1 - oam_index
;* \2 - tile index
;* clobbers:
;* a
;***************************************************************************
set_16x16_Tile: MACRO
ld a,\2
ld [shadowOAM + (\1 * 4) + 2],a
ld a,\2 + 2
ld [shadowOAM + ((\1 + 1) * 4) + 2],a
ENDM
;***************************************************************************
;*
;* set_16x16_Pos - Sets an entire 16x16 sprite, assuming sequential tile
;* numbers, and sequential OAM table entries.
;*
;* arguments:
;* \1 - oam index
;* \2 - x coordinate
;* \3 - y coordinate
;* clobbers:
;* a
;***************************************************************************
set_16x16_Pos: MACRO
ld a,\2
ld [shadowOAM + (\1 * 4) + 1], a
ld a,\2 + 8
ld [shadowOAM + ((\1 + 1) * 4) + 1], a
ld a,\3
ld [shadowOAM + (\1 * 4) + 0], a
ld [shadowOAM + ((\1 + 1) * 4) + 0], a
ENDM
;***************************************************************************
;*
;* set_16x16_Pos - Sets an entire 16x16 tile. Assumes source tile is arranged
;* in top-left to bottom-right order in VRAM.
;*
;* inputs:
;* a - source tile top-left
;* hl - destination address (within VRAM bank, ideally)
;* clobbers:
;* a, hl, bc
;***************************************************************************
draw_16x16_tile: MACRO
ld [hl+], a
inc a
ld [hl+], a
ld bc, 30
add hl, bc
inc a
ld [hl+], a
inc a
ld [hl], a
ENDM
;***************************************************************************
;*
;* map_Tile_Address - Given tile coordinates, calculates the memory address
;* of the given tile, based on the map size
;*
;* inputs:
;* bc - tile y-coordinate
;* de - tile x-coordinate
;* outputs:
;* hl - map address of selected tile
;* clobbers:
;* bc, a
;***************************************************************************
map_Tile_Address:
ld a, 4
ld h, b
ld l, c
.mul_loop:
add hl, hl
dec a
jr nz, .mul_loop
; at this point, hl represents y * map_width. First add it to the base
; address of the map
getWordBC MapAddress
add hl, bc
; and add the X coordinate
; CHEAT: restrict the X coordinate to map width
ld a, e
and %00001111
ld e, a
ld d, 0
add hl, de
; that's it!
ret
;***************************************************************************
;*
;* vram_Masked_Tile_Address - Given tile coordinates, calculates the VRAM
;* address where the destination tile should START.
;*
;* inputs:
;* bc - logical tile y-coordinate
;* de - logical tile x-coordinate
;* outputs:
;* hl - map address of selected tile
;* clobbers:
;* de, a
;***************************************************************************
vram_Masked_Tile_Address:
ld h, $98
; x coordinate; this only affects 'l' because it cannot overflow
ld a, e
and %00001111
sla a
ld l, a
; y coordinate: "multiply by 64" (32 h-tiles to skip, 2 rows)
ld a, c
and %00001111
ld b, a
ld c, 0
REPT 2
srl b
rr c
ENDR
add hl, bc
ret
;***************************************************************************
;*
;* update_Camera - Moves the camera towards its target location, and updates
;* internal tile tracking registers for tile drawing routines to use
;* clobbers:
;* TODO
;***************************************************************************
update_Camera:
; TODO: rate limit this
getWordHL TargetCameraX
setWordHL CurrentCameraX
REPT 4
sra h
rr l
ENDR
setWordHL CurrentTileX
getWordHL TargetCameraY
setWordHL CurrentCameraY
REPT 4
sra h
rr l
ENDR
setWordHL CurrentTileY
call update_Bg_Scroll
;ld a, [FrameCounter+1]
;bit 0, a
;jp z, .updateRow
.updateColumn
; update entire perimiter (INEFFICIENT!!)
getWordDE CurrentTileX
ld hl, 10
add hl, de
ld d, h
ld e, l
call draw_Column
ret
;.updateRow
; getWordBC CurrentTileY
; ld hl, 9
; add hl, bc
; ld b, h
; ld c, l
; call draw_Row
; ret
;***************************************************************************
;*
;* update_Bg_Scroll - Moves the hardware scrolling registers into position
;* clobbers:
;* TODO
;***************************************************************************
update_Bg_Scroll:
ld a, [CurrentCameraX + 1]
ld [rSCX], a
ld a, [CurrentCameraY + 1]
ld [rSCY], a
ret
;***************************************************************************
;*
;* draw_Column - Given a logical tile coordinate, draws all tiles in the
;* column that would be visible (based on the current Y coordinate)
;* input:
;* de: logical column
;***************************************************************************
draw_Column:
; calculate our starting coordinate in map space
getWordBC CurrentTileY
call map_Tile_Address ; result in hl, clobbers bc
push hl
; calculate our destination coordinate in VRAM
getWordBC CurrentTileY
call vram_Masked_Tile_Address ; result in hl, clobbers de
pop de ; de = source address
REPT 16
ld a, [de]
; multiply the logical tile by four
sla a
sla a
draw_16x16_tile
; hl now points to bottom-right tile, we need to adjust it to
; the top-left of the next tile vertically
dec hl ; one left
ld bc, 32 ; one down
add hl, bc
; fix bank edge
ld a, h
and %00000011
or $98
ld h, a
; preserve hl
push hl
; add map width to de, advancing to the next row
push de
pop hl
ld a, 16
ld c, a
add hl, bc
push hl
pop de
pop hl
ENDR
ret
;***************************************************************************
;*
;* draw_Row - Given a logical tile coordinate, draws all tiles in the
;* row that would be visible (based on the current X coordinate)
;* input:
;* bc: logical row
;***************************************************************************
draw_Row:
; calculate our starting coordinate in map space
getWordDE CurrentTileX
push bc
call map_Tile_Address ; result in hl, clobbers bc
pop bc
push hl
call vram_Masked_Tile_Address ; result in hl, clobbers de
pop de ; de = source address
REPT 11
ld a, [de]
; multiply the logical tile by four
sla a
sla a
push hl
draw_16x16_tile
pop hl ; hl points to original tile
ld a, l
and a, %11100000
ld c, a ; c = row bits to preserve
ld a, l
add a, 2
and a, %00011111
or a, c
ld l, a
inc de
ENDR
ret
;***************************************************************************
;*
;* init_Viewport - Draws every tile currently on-screen at the camera's
;* coordinates. This is inefficient, and meant to be called when first
;* starting the game.
;*
;* clobbers:
;* yes
;***************************************************************************
init_Viewport:
getWordBC CurrentTileY
getWordDE CurrentTileX
ld h, 9
.loop
push bc
push de
push hl
call draw_Row
pop hl
pop de
pop bc
inc bc
dec h
jr nz, .loop
ret
;***************************************************************************
;* updateSprites - Call this once per game update. Runs through all sprites
;* and determines their current animation frame, position, and other
;* attributes, before writing the values to shadow OAM
;***************************************************************************
updateSprites:
ld de, SpriteList
ld b, 0
.loop
push bc
ld hl, SPRITE_ACTIVE
add hl, de
ld a, [hl]
cp 0
jp nz, .active
.inactive
inc hl ; move to the start of the next entry (+2 bytes from here)
inc hl
push hl ; replace de with hl contents using the stack
pop de
pop bc
inc b
ld a, 17
cp b
jp z, .end
jp .loop
.active
ld hl, shadowOAM
ld a, b
sla a ; x8 (two OAM entries per 16x16 tile)
sla a
sla a
add a, l ;no overflow possible due to alignment
ld b, h
ld c, a
; bc now points to shadow OAM entry for this sprite
; de now points to the start of this sprite entry
push de
push bc
call .updateAnimation
pop bc
pop de
push de
push bc
call .updatePosition
pop bc
pop de
.finishUpdate
ld hl, 13
add hl, de
ld d, h
ld e, l ; de now points to the next sprite in sequence
pop bc ; pop again here to restore bc as the counter
inc b
ld a, 17
cp b
jp nz, .loop
.end
ret
;* inputs:
;* SP+2 - OAM entry
;* SP+4 - logical sprite entry
.updatePosition
; is this a HUD sprite? If so, skip a ton of this logic
getStackBC 4
ld hl, SPRITE_HUD_SPACE
add hl, bc
ld a, [hl]
cp 0
jp z, .chunkSpace
; HUD space uses the object's X and Y coordinates directly
getStackBC 4
ld hl, SPRITE_X_POS ;high byte only
add hl, bc
ld a, [hl]
ld [tPosX], a
ld a, 0
ld [tPosX+1], a
getStackBC 4
ld hl, SPRITE_Y_POS ;high byte only
add hl, bc
ld a, [hl]
ld [tPosY], a
ld a, 0
ld [tPosY+1], a
; done! Jump past all the chunk calculation logic and continue with animation logic.
jp .worldSpace
.chunkSpace
; start with the left-most pixel of the active chunk
ld a, [CurrentCameraX+1]
ld [tDebugScrollX], a
ld d, 0
ld e, a
ld hl, 0
; test to see if the camera coordinate is greater than 96
ld a, 96
sub e
jp nc, .less
ld hl, 256
.less
; subtract the camera coordinates from hl
ld a, l
sub e
ld l, a
ld a, h
sbc d
; al now contains the left-most coordinate of the active chunk
; stash this in de for later
ld d, a
ld e, l
; determine the difference between the active chunk and this object's chunk
getStackBC 4
ld hl, SPRITE_CHUNK ;high byte only
add hl, bc
ld b, [hl]
ld a, [currentChunk]
ld c, a
ld a, b
sub c ; b now contains how far behind / ahead of the active chunk we are.
ld b, a
; Translate this value into 256 * b
ld c, 0
; bc contains chunk offset in pixels. Add it to de to obtain the left-most coordinate of the object's chunk
ld h, d
ld l, e
add hl, bc
; stash this in de again
ld d, h
ld l, e
; Grab the object's X coordinate
getStackBC 4
ld hl, SPRITE_X_POS ;high byte only
add hl, bc
ld a, [hl]
; add it to our running total in de
ld h, 0
ld l, a
add hl, de
; hl now contains the sprite's coordinate within its chunk. Stash this for now.
ld a, l
ld [tPosX], a
ld a, h
ld [tPosX+1], a
; Determine the Y coordinate of the active chunk. This is simpler because we don't care about wrapping,
; so the Y coordinate is effectively 0 - scrY
ld a, [CurrentCameraY+1]
ld b, a
ld a, 0
sub b
ld e, a
; e now contains the Y coordinate of the active chunk
getStackBC 4
ld hl, SPRITE_Y_POS ;high byte only
add hl, bc
ld a, [hl]
; add in the t coordinate of the chunk
add e
; stash this for later
ld [tPosY], a
.worldSpace
; Here, calculate the animation offsets, and add those to our working set for X and Y
getStackBC 4
ld hl, SPRITE_ANIMATION_CURRENT
add hl, bc
ld a, [hl+]
ld e, a
ld d, [hl]
; de now points at animation data for current frame
inc de ; skip duration
inc de ; skip tile index
; de now points to the X offset
ld a, [de]
push de ; stash this, since we'll clobber it below with X offset calculations
ld c, a
; extend sign bit into high byte
ld b, 0
bit 7, c
jp z, .positive
ld b, $FF
.positive
; read working position into de
ld hl, tPosX
ld e, [hl]
inc hl
ld d, [hl]
; add our animation offset to it
ld h, b
ld l, c
add hl, de
; hl now contains our final on-screen X coordinate
; RANGE CHECK: Is this sprite offscreen?
; stash original X coordinate in bc
ld b, h
ld c, l
setWordBC tDebugFinalX
ld hl, 16
add hl, bc ; hl now contains original coordinate +16
bit 7, h ; if hl is still negative, we are offscreen to the left. Bail!
jp nz, .hideSprite
ld hl, -160
add hl, bc ; hl now contains original coordinate - 160
bit 7, h ; if hl is still positive, we are offscreen to the right. Bail here too!
jp z, .hideSprite
; if we got here, this sprite is on-screen! Grab the low byte of the coordinate, add 8 to it (OAM quirk), and
; stash it for later.
ld a, 8
add a, c
ld [tPosX], a
; Calculate the animation offset for Y
pop de
inc de
ld a, [de] ; a now contains Y-offset for this animation
ld hl, tPosY
add a, [hl] ; add it directly to tPosY on disk
ld [hl], a
; finally, write these values to OAM
getStackBC 2
ld h, b
ld l, c
ld a, [tPosY]
ld [hl+], a
ld a, [tPosX]
ld [hl+], a
; and again, for the second OAM entry
inc hl
inc hl
ld a, [tPosY]
ld [hl+], a
ld a, [tPosX]
add a, 8
ld [hl+], a
ret
.hideSprite
; Firstly, pop de off the stack from earlier, since otherwise we skipped doing that
pop de
; now we need to hide the sprite in OAM. can do this by setting its Y coordinate offscreen (ie, to 0xFF)
getStackBC 2
ld h, b
ld l, c
ld a, $FF
ld [hl], a
; and again for the second OAM entry
REPT 4
inc hl
ENDR
ld [hl], a
; done!
ret
;* inputs:
;* SP+2 - OAM entry
;* SP+4 - logical sprite entry
.updateAnimation
getStackBC 4
ld hl, SPRITE_ANIMATION_DURATION
add hl, bc
dec [hl]
jp z, .nextFrame
ret
.nextFrame
getStackBC 4
ld hl, SPRITE_ANIMATION_CURRENT
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
; de now contains current animation pointer
ld hl, 5
add hl, de
ld d, h
ld e, l
; de now contains NEXT animation pointer
ld a, [de]
; if duration is zero, this signals the end of the animation list
cp 0
jp nz, .applyNextFrame
.restartAnimation
; Grab the starting address for this animation
getStackBC 4
ld hl, SPRITE_ANIMATION_START
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
; de now contains the address of the starting frame. Write this
; out to the current frame to reset the animation
.applyNextFrame
getStackBC 4
ld hl, SPRITE_ANIMATION_CURRENT
add hl, bc
ld [hl], e
inc hl
ld [hl], d
; de still contains the current animation pointer, so proceed to
; update OAM with the new state
; Set our delay to the duration for the current frame
getStackBC 4
ld hl, SPRITE_ANIMATION_DURATION
add hl, bc
ld a, [de]
ld [hl], a
; Determine the base tile index for this frame
getStackBC 4
ld hl, SPRITE_TILE_BASE
add hl, bc
ld a, [hl]
; Multiply the base index by 4
sla a
sla a
ld b, a
; add it to the logical index for this animation
inc de
ld a, [de]
sla a ; multiply that by 4 also
sla a
add a, b
ld b, a
; b now contains the final tile index for this animation
; skip to the OAM attributes
inc de
inc de
inc de
ld a, [de]
ld c, a
; c now contains the OAM attributes
; Update our OAM tile to the index for this frame
getStackDE 2
ld hl, 2
add hl, de
ld [hl], b ; write the tile index
inc hl
ld [hl], c ; write the OAM attributes
inc b ; skip to the next 8x16 tile
inc b
ld de, 3
add hl, de
ld [hl], b ; write the next tile index
inc hl
ld [hl], c ; write the OAM attributes
; and we're done!
ret
;***************************************************************************
;* initSprites - Just zeroes out sprite memory. That's all!
;***************************************************************************
initSprites:
ld hl, SpriteList
ld d, 17*13
.loop
ld [hl], 0
inc hl
dec d
jp nz, .loop
ret
;***************************************************************************
;* spawnSprite - Creates a new sprite, at the specified index, with the
;* provided animation data
;* inputs:
;* a - desired index
;* bc - animation address
;* outputs:
;* bc - sprite address
;***************************************************************************
spawnSprite:
setSpriteAnimation: ;cheaty mc-cheat face
ld hl, SpriteList
cp 0
jp z, .spawn
ld de, 13
.loop
add hl, de
dec a
jp nz, .loop
.spawn
push hl
; hl now points to the start of the sprite entry
ld de, SPRITE_ANIMATION_START
add hl, de
ld a, c
ld [hl+], a
ld a, b
ld [hl+], a
; cheat here: decrement the animation start value by 5
dec bc
dec bc
dec bc
dec bc
dec bc
; write this "pre-animation" pointer to the sprite "current" entry
ld a, c
ld [hl+], a
ld a, b
ld [hl+], a
pop bc ; bc now points to the sprite entry
; now set a few variables to kick-start the sprite's animation state
setFieldByte SPRITE_ACTIVE, 1
; this causes the animation to immediately skip to the first frame,
; because we seeded it with frame -1 earlier
setFieldByte SPRITE_ANIMATION_DURATION, 1
; That's it!
ret
;***************************************************************************
;* getSpriteAddress - Retrieve a sprite's memory address, by index
;* input:
;* a - desired index
;* output:
;* bc - address
;* clobbers:
;* a, hl
;***************************************************************************
getSpriteAddress:
ld hl, SpriteList
cp 0
jp z, .done
ld bc, 13
.loop
add hl, bc
dec a
jp nz, .loop
.done
ld b, h
ld c, l
ret
;***************************************************************************
;* vblankRoutine - Called automatically by the hardware at the start of
;* the vertical blanking period. Beware: time sensitive! Must complete
;* all activities before vertical blanking ends.
;***************************************************************************
vblankRoutine:
push af
push bc
push de
push hl
call oamDMA
getWordBC FrameCounter
inc bc
setWordBC FrameCounter
pop hl
pop de
pop bc
pop af
reti
POPS
PUSHS
SECTION "vBlank Jump Vector",ROM0[$40]
vblankJumpVector:
jp vblankRoutine
POPS