-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgbdemo.asm
963 lines (841 loc) · 28.9 KB
/
gbdemo.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
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
; =============================================================================
; Gameboy DEMO
; (C) by Jens Ch. Restemeier, <XXXXXXXXXXXX>
; =============================================================================
#include "gameboy.inc"
lorambase = 0c0a0h ; some space for the sprite-table
hirambase = 0ff80h
#DEFINE LOBYTEVAR(X) X = lorambase \lorambase .set (lorambase + 1)
#DEFINE HIBYTEVAR(X) X = hirambase \hirambase .set (hirambase + 1)
#DEFINE LOWORDVAR(X) X = lorambase \lorambase .set (lorambase + 2)
#DEFINE HIWORDVAR(X) X = hirambase \hirambase .set (hirambase + 2)
; == variables in hi-ram ==
HIBYTEVAR(GB_VERSION)
HIBYTEVAR(JOY_TIPP)
HIBYTEVAR(JOY_HOLD)
HIBYTEVAR(OLD_JOY_HOLD)
HIWORDVAR(IRQ_HANDLER)
HIBYTEVAR(SEM_VBLANK)
HIBYTEVAR(SCREEN)
HIBYTEVAR(EN_SOUND)
HIBYTEVAR(EN_COLOR)
HIBYTEVAR(HAS_COLOR)
; all variables for the sound-player
HIWORDVAR(VOICE_1)
HIBYTEVAR(DUR_1)
HIWORDVAR(VOICE_2)
HIBYTEVAR(DUR_2)
HIWORDVAR(VOICE_3)
HIBYTEVAR(DUR_3)
HIBYTEVAR(PLAY_VOICES)
; variables for APA-demonstration
; rotation-angle
HIBYTEVAR(rot)
; matrix
HIBYTEVAR(m00)
HIBYTEVAR(m01)
HIBYTEVAR(m10)
HIBYTEVAR(m11)
HIBYTEVAR(x1)
HIBYTEVAR(y1)
HIBYTEVAR(x2)
HIBYTEVAR(y2)
HIBYTEVAR(radius)
HIBYTEVAR(color)
HIBYTEVAR(xc)
HIBYTEVAR(yc)
HIBYTEVAR(i1)
HIBYTEVAR(i2)
HIBYTEVAR(sx)
HIBYTEVAR(sy)
HIWORDVAR(d)
; some screens need a "slow-down" counter
HIBYTEVAR(speed)
; variables for S_FLI.INC
HIBYTEVAR(tabidx)
HIWORDVAR(textpos)
; variables for the printer driver
HIWORDVAR(crc)
HIBYTEVAR(stat_1)
HIBYTEVAR(stat_2)
; variables for the tiny game
HIBYTEVAR(xpos)
HIBYTEVAR(hpos)
HIBYTEVAR(heli_x)
HIBYTEVAR(heli_y)
HIWORDVAR(g_points)
; variables for paradroid-game
HIBYTEVAR(lsig)
HIBYTEVAR(rsig)
; allocate some memory for the SGB packet-buffer
sgb_packet = lorambase
lorambase .set (lorambase + 16)
; allocate some memory for the projected points
t_points = lorambase
lorambase .set (lorambase + 256)
; == end of variables ==
vblank_address = hirambase ; last item in hiram is the Sprite-DMA function
; == constants: ==
; gameboy versions:
UNKNOWN = 0
CLASSIC_GAMEBOY = 1
SUPER_GAMEBOY = 2
POCKET_GAMEBOY = 3
COLOR_GAMEBOY = 4
; =============================================================================
.org 0
; Try "TYPE GBDEMO.GB" to see this:
.text "GameBoy DEMO"
; This is: LF, CR, EOF
.byte 00ah,00dh,01ah
; =============================================================================
.org 020h
; =============================================================================
; Wait for VBL - destroys AF. To be called with "rst 20h"
; =============================================================================
ldh a,(LCDC & 0FFh)
bit 7,a
ret z
waitvbl: ldh a,(LCDC & 0FFh) ; Wait for VBL
add a,a
ret nc
notyet: ldh a,(LY & 0FFh)
cp 90h
jr nz,$-4
ret
; = IRQ vectors =
.org 040h ; VBlank IRQ
; jump to where we copied the DMA-function to...
jp vblank_address
.org 048h ; LCDC Status IRQ
; all FLI-effects are done here:
jr s_irq
.org 050h ; Timer Owerflow IRQ
reti
.org 058h ; Serial Transfer Completion IRQ
reti ; Do nothing
.org 060h ; Joypad action (?) IRQ
reti ; Do nothing
; Irqs done..
.org 070h
bitmask:
; A table for a index-to-bitmask translation
; The address (070h) is hardcoded
.byte 080h,040h,020h,010h,008h,004h,002h,001h,000h
.org 080h
; A table for a fast conversion from a nibble to a hex char
hextable:
.byte "0123456789ABCDEF"
.org 090h
; A table with cosinus values
cos_table:
.byte 64, 62, 59, 53, 45, 35, 24, 12, 0, -12, -24, -35, -45, -53, -59, -62
.byte -64, -62, -59, -53, -45, -35, -24, -12, 0, 12, 24, 35, 45, 53, 59, 62
; - Additional IRQ functions ----------------------------------------------
; indirect FLI function
s_irq:
push af
push bc
push de
push hl
call sub_irq ; put adr of irq-exit on stack
pop hl
pop de
pop bc
pop af
reti
sub_irq: ld hl,IRQ_HANDLER
ldi a,(hl)
ld d,a
ld a,(hl)
ld e,a
push de ; push handler-address on stack
ret
; = Gameboy Header ============================================================
.org 100h
nop
jp start
.byte $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83 ; Nintendo Logo
.byte $00,$0C,$00,$0D,$00,$08,$11,$1F,$88,$89,$00,$0E
.byte $DC,$CC,$6E,$E6,$DD,$DD,$D9,$99,$BB,$BB,$67,$63
.byte $6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
.byte "GAMEBOY DEMO " ; Cart name 14bytes
.byte 080h ; Color GB
.word 0FFFFh ; No Vendor
.byte 003h ; Super GB functions
.byte 0 ; Cart type ROM Only
.byte 0 ; ROM Size 32k
.byte 0 ; RAM Size 0k
.byte 0 ; destination: non-japanese
.byte 033h ; Maker ID -> new scheme
.byte 1 ; Version
.byte 0FFh ; Complement check
.word 0ffffh ; Cheksum
; =============================================================================
; == startup code ==
start: di
; init stack
ld sp,0fffeh
; let's find out, what kind of GB we have
; first the easy stuff: GB Color and GB pocket
cp 011h
jr nz, no_CGB
ld a, COLOR_GAMEBOY
jr gb_found
no_CGB: cp 0FFh
jr nz, no_PGB
ld a, POCKET_GAMEBOY
jr gb_found
no_PGB: cp 001h
jr nz, no_GB
; to distinguish Super GB and classic GB try a MLT_REQ
call clear_packet
ld a,010001001b ; MLT_REQ
ld (sgb_packet),a
ld a,000000011b ; request 5 players
ld (sgb_packet+1),a
call send_packet
ld a, 030h
ldh (P1 & 0FFh), a
ldh a, (P1 & 0FFh)
ldh a, (P1 & 0FFh)
ldh a, (P1 & 0FFh)
ldh a, (P1 & 0FFh)
ldh a, (P1 & 0FFh)
and 00fh
cp 00fh
jr nz, sgb_found
ld a, 000h
ldh (P1 & 0FFh), a
ld a, 030h
ldh (P1 & 0FFh), a
ldh a, (P1 & 0FFh)
ldh a, (P1 & 0FFh)
ldh a, (P1 & 0FFh)
ldh a, (P1 & 0FFh)
ldh a, (P1 & 0FFh)
and 00fh
cp 00fh
jr nz, sgb_found
ld a, CLASSIC_GAMEBOY
jr gb_found
sgb_found:
; we don't need 5-player mode, disable it again
ld a,010001001b
ld (sgb_packet),a
ld a,000000000b ; no request
ld (sgb_packet+1),a
call send_packet
ld a, SUPER_GAMEBOY
jr gb_found
no_GB: ld a, UNKNOWN
gb_found: ld (GB_VERSION),a ; store GB-version
; clear ram
ld hl, 0C000h
ld de, 02000h
clear_ram: xor a
ldi (hl),a
dec de
ld a,d
or e
jp nz,clear_ram
; clear hiram, except GB-version
ld c, 081h
ld d, 07Eh
clear_hiram: xor a
ld (c),a
inc c
dec d
jp nz, clear_hiram
; copy vblank handler into hiram
ld c,(vblank_address & 0FFh)
ld hl,vblank_start
ld de,(vblank_stop-vblank_start)
copy_func: ldi a,(hl)
ld (c),a
inc c
dec de
ld a,d
or e
jr nz, copy_func
call default_init
ld hl, text_font ; install the text-font
ld de, 09000h
ld bc, 128*8*2
call copy_nv
; init configuration
ld a,1
ldh (EN_SOUND & 0FFh),a ; enable sound
ldh (HAS_COLOR & 0FFh),a
ldh (EN_COLOR & 0FFh),a ; enable color (if present)
ld a,(GB_VERSION)
cp COLOR_GAMEBOY ; Is it a GB-Color ?
jr z, gb_color
; ... no time to support SGB-color ...
; cp SUPER_GAMEBOY ; Is it a Super-GB ?
; jr z, gb_color
ld a,0 ; all other cases: color n/a
ldh (HAS_COLOR & 0FFh),a
ldh (EN_COLOR & 0FFh),a
gb_color:
call display_on
call init_sound
ei ; let's go !
restart: ; set start-screen
ld a,0
ldh (SCREEN & 0FFh),a
; == main loop ==
main:
call readjoy
ldh a, (JOY_HOLD & 0FFh) ; check for start+select+a+b=reset
cp 00fh
jr z, restart
call dispatch ; execute slice of the game
sleep: halt ; save engergy
nop ; avoid hlt-bug
ld a,(SEM_VBLANK) ; The only IRQ we want is VBLANK
or a
jr z,sleep
xor a
ld (SEM_VBLANK),a
jr main
; =============================================================================
; Execute one slice of the game. Could be extended to switch banks
; =============================================================================
dispatch:
ldh a,(SCREEN & 0FFh)
sla a
ld hl,jump_table
add a,l
ld l,a
ld a,h
adc a,0
ldi a,(hl)
ld c,a
ld a,(hl)
ld b,a
push bc
nothing: ret
jump_table: .word drw_start ; 0
.word s1_start ; 1
.word s2_start ; 2
.word s3_start ; 3
.word drw_adr ; 4
.word s1_adr ; 5
.word drw_opt ; 6
.word s1_opt ; 7
.word s2_opt ; 8
.word s3_opt ; 9
.word s4_opt ; 10
.word drw_test ; 11
.word hnd_test ; 12
.word rdrw_test ; 13
.word drw_fli ; 14
.word s1_fli ; 15
.word s2_fli ; 16
.word s3_fli ; 17
.word drw_apa ; 18
.word s1_apa ; 19
.word s2_apa ; 20
.word s2_adr ; 21
.word drw_game ; 22
.word s1_game ; 23
.word s2_game ; 24
.word s3_game ; 25
.word drw_para ; 26
.word s1_para ; 27
.word nothing
; =============================================================================
; VBLANK IRQ-function, to be copied into HiRAM
; =============================================================================
vblank_start:
push af
ld a,1 ; set vblank semaphore
ldh (SEM_VBLANK & 0FFh),a
ld a,0c0h ; start sprite-DMA
ldh (SPRDMA & 0FFh),a
ld a,28h ; wait until DMA is over
dec a
jr nz,$-1
pop af
jp timer_irq
; reti
vblank_stop:
; =============================================================================
; Initialise GB into a known state
; =============================================================================
default_init:
ld hl, sprite_a ; install the sprites
ld de, 08000h
ld bc, 24*8*2
call copy_nv
xor a ; Misc standard init things..
ldh (STAT & 0FFh),a ; LCDC Status
ldh (SCX & 0FFh),a ; Screen scroll Y=0
ldh (SCY & 0FFh),a ; Screen scroll X=0
ld a, 0FFh
ldh (LYC & 0FFh), a ; LYC outside of used area
ldh (WX & 0FFh),a ; Window X - not visible
ldh (WY & 0FFh),a ; Window Y - not visible
call display_off
ld a,01000011b ; LCD Controller = Off (No picture on screen)
; WindowBank = $9C00
; Window = OFF
; BG Chr = $8800
; BG Bank= $9800
; OBJ = 8x8
; OBJ = On
; BG = On
ldh (LCDC & 0FFh),a
ld a,11100100b ; grey 3=11 (Black)
; grey 2=10 (Dark grey)
; grey 1=01 (Light grey)
; grey 0=00 (Transparent)
ldh (BGP & 0FFh),a ; background
ldh (OBP0 & 0FFh),a ; sprites a
ldh (OBP1 & 0FFh),a ; sprites b
ld a,000000000b ; disable all IRQ
ldh (IE & 0FFh),a
; install dummy-IRQ-handler
ld de, nothing
ld hl, IRQ_HANDLER
ld a, d
ldi (hl),a
ld a, e
ld (hl), e
ld a,000000001b ; enable VBLANK and Timer IRQ
ldh (IE & 0FFh),a
; hide/clear all sprites
ld c,09fh
xor a
ld hl, 0c000h
dil1: ldi (hl),a
dec c
jr nz, dil1
; set attributes to 0 (screen 1 and screen 2)
ld a, 1 ; switch to attribute RAM
ldh (VBK & 0FFh),a
ld hl, 09800h
ld bc, 0800h
xor a ; no atr/palette 0
call fill_nv
ld a, 0 ; switch to normala RAM
ldh (VBK & 0FFh),a
; clear bg map (screen 1 and screen 2)
ld hl, 09800h
ld bc, 0800h
xor a ; should be blank in a font
call fill_nv
ret
; =============================================================================
; Switch off LCD-display
; =============================================================================
display_off:
rst 20h ; wait for vbl
ld hl,LCDC
res 7,(hl) ; display off
res 1,(hl) ; bg off
res 0,(hl) ; ob off
ret
; =============================================================================
; Switch on LCD-display
; =============================================================================
display_on:
ld hl,LCDC
set 7,(hl) ; display on
set 1,(hl) ; bg on
set 0,(hl) ; ob on
ret
; =============================================================================
; wait for one frame
; =============================================================================
wait_frame: ldh a,(STAT & 0FFh) ; wait for vbl
and 3
cp 001b
jr nz, wait_frame
wf_l1: ldh a,(STAT & 0FFh) ; wait for vbl
and 3
cp 001b
jr z, wf_l1
ret
; =============================================================================
; Wait for a key
; =============================================================================
wait_key: call readjoy
ld a,(JOY_TIPP)
or a
jp z,wait_key
ret
; =============================================================================
; Read joypad
; =============================================================================
readjoy: ld a,020h ; read first nibble
ldh (JOYPAD & 0FFh),a
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
cpl
and 00fh
swap a
ld b,a
ld a,010h ; read second nibble
ldh (JOYPAD & 0FFh),a
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
ldh a,(JOYPAD & 0FFh)
cpl
and 00fh
or b ; combine them
ld c,a
ldh a,(JOY_HOLD & 0FFh)
ldh (OLD_JOY_HOLD & 0FFh),a
xor c
and c
ldh (JOY_TIPP & 0FFh),a
ld a,c
ldh (JOY_HOLD & 0FFh),a
ld a,030h
ldh (JOYPAD & 0FFh),a
ret
; =============================================================================
; copy bc, no wait for vblank
; =============================================================================
copy_nv:
ldi a,(hl)
ld (de),a
inc de
dec bc
ld a,b
or c
jr nz, copy_nv
ret
; =============================================================================
; copyz, waiting for vblank, hl=source, de=adr end='0'
; =============================================================================
copy_z:
ldh a,(STAT & 0FFh)
bit 1,a
jr nz,copy_z
ldi a,(hl)
or a
ret z
ld (de),a
inc de
jr copy_z
; =============================================================================
; Fill bc bytes from hl with a, no wait for vblank
; =============================================================================
fill_nv: ld d,a
f1_l1: ld a,d
ldi (hl),a
dec bc
ld a,b
or c
jp nz,f1_l1
ret
; =============================================================================
; Set attrib "box", position hl, width b, height c, d attrib
; =============================================================================
set_atr_box:
ld a, 1 ; switch to attribute RAM
ldh (VBK & 0FFh),a
sab_l2:
push bc
push hl
ld a,d
sab_l1: ldi (hl),a
dec b
jr nz, sab_l1
pop hl
ld bc,32
add hl,bc
pop bc
dec c
jr nz, sab_l2
ld a, 0
ldh (VBK & 0FFh),a
ret
; =============================================================================
; draw a nice border, position hl, width-4 b, height-4 c
; =============================================================================
draw_border:
; draw upper line
push hl
push bc
ld a, 1
ldi (hl),a
ld a, 3
ldi (hl),a
db_l1: ld a, 16
ldi (hl),a
dec b
ld a,b
or a
jr nz, db_l1
ld a, 5
ldi (hl),a
ld a, 4
ld (hl),a
pop bc
pop hl
ld de,32
add hl,de
; second line
push hl
push bc
ld a, 2
ldi (hl),a
ld a, 2
add a, b
add a, l
ld l,a
ld a,h
adc a,0
ld h,a
ld a, 6
ld (hl),a
pop bc
pop hl
ld de,32
add hl,de
db_l2: ; middle lines
push hl
push bc
ld a, 15
ldi (hl),a
ld a, 2
add a, b
add a, l
ld l,a
ld a,h
adc a,0
ld h,a
ld a, 13
ld (hl),a
pop bc
pop hl
ld de,32
add hl,de
dec c
ld a,c
or a
jr nz,db_l2
; one-before-last line
push hl
push bc
ld a, 12
ldi (hl),a
ld a, 2
add a, b
add a, l
ld l,a
ld a,h
adc a,0
ld h,a
ld a, 8
ld (hl),a
pop bc
pop hl
ld de,32
add hl,de
; draw last line
push hl
push bc
ld a, 10
ldi (hl),a
ld a, 11
ldi (hl),a
db_l3: ld a, 14
ldi (hl),a
dec b
ld a,b
or a
jr nz, db_l3
ld a, 9
ldi (hl),a
ld a, 7
ld (hl),a
pop bc
pop hl
ret
; =============================================================================
; setup background palette entry, hl=address, a=slot
; =============================================================================
set_bg_pal:
sla a ; entry-nr a*8
sla a
sla a
or 010000000b ; auto-increment, from 0
ldh (BCPS & 0FFh), a
ldi a,(hl)
ldh (BCPD & 0FFh), a
ldi a,(hl)
ldh (BCPD & 0FFh), a
ldi a,(hl)
ldh (BCPD & 0FFh), a
ldi a,(hl)
ldh (BCPD & 0FFh), a
ldi a,(hl)
ldh (BCPD & 0FFh), a
ldi a,(hl)
ldh (BCPD & 0FFh), a
ldi a,(hl)
ldh (BCPD & 0FFh), a
ldi a,(hl)
ldh (BCPD & 0FFh), a
ret
; =============================================================================
; setup object palette entry, hl=address, a=slot
; =============================================================================
set_ob_pal:
sla a ; entry-nr a*8
sla a
sla a
or 010000000b ; auto-increment, from 0
ldh (OCPS & 0FFh), a
ldi a,(hl)
ldh (OCPD & 0FFh), a
ldi a,(hl)
ldh (OCPD & 0FFh), a
ldi a,(hl)
ldh (OCPD & 0FFh), a
ldi a,(hl)
ldh (OCPD & 0FFh), a
ldi a,(hl)
ldh (OCPD & 0FFh), a
ldi a,(hl)
ldh (OCPD & 0FFh), a
ldi a,(hl)
ldh (OCPD & 0FFh), a
ldi a,(hl)
ldh (OCPD & 0FFh), a
ret
; =============================================================================
; set complete palette to gray
; =============================================================================
set_gray:
ld a,0
ld hl, gray_pal
call set_bg_pal
ld a,1
ld hl, gray_pal
call set_bg_pal
ld a,2
ld hl, gray_pal
call set_bg_pal
ld a,3
ld hl, gray_pal
call set_bg_pal
ld a,4
ld hl, gray_pal
call set_bg_pal
ld a,5
ld hl, gray_pal
call set_bg_pal
ld a,6
ld hl, gray_pal
call set_bg_pal
ld a,7
ld hl, gray_pal
call set_bg_pal
ld a,0
ld hl, gray_pal
call set_ob_pal
ld a,1
ld hl, gray_pal
call set_ob_pal
ld a,2
ld hl, gray_pal
call set_ob_pal
ld a,3
ld hl, gray_pal
call set_ob_pal
ld a,4
ld hl, gray_pal
call set_ob_pal
ld a,5
ld hl, gray_pal
call set_ob_pal
ld a,6
ld hl, gray_pal
call set_ob_pal
ld a,7
ld hl, gray_pal
call set_ob_pal
ret
; =============================================================================
; = a simple sound-player =
#include "SOUND.INC"
; = actions for start screen =
#include "S_START.INC"
; = actions for address screen =
#include "S_ADR.INC"
; = actions for options screen =
#include "S_OPT.INC"
; = actions for joypad test =
#include "S_TEST.INC"
; = actions for FLI demo =
#include "S_FLI.INC"
; = graphics demo =
#include "S_GBAPA.INC"
; = game =
#include "S_GAME.INC"
; = paradroid logic-game =
#include "S_PARA.INC"
; = super-gb utilities =
#include "SGB.INC"
; = GB-printer =
#include "PRINTER.INC"
; = Decompression of packed data =
;#include "DECOMP.INC"
; = text_strings =
#include "TEXT.INC"
; = some random data =
#include "RANDOM.INC"
; = game data =
; an 8x8 4-color font... nothing beautifull
#include "FONT.INC"
; a few ugly sprites
#include "SPRITES.INC"
; color_palettes
gray_pal:
.word 32767
.word 21140
.word 10570
.word 0
red_pal:
.word 32767
.word 21151
.word 10591
.word 31
gold_pal:
.word 32767
.word 1023
.word 11263
.word 21503
blue_pal:
.word 32767
.word 32404
.word 32074
.word 31744
; =============================================================================
; Single bank/second bank: check for ROM-overflow
#if ($ > 07FFFh)
ROM_OVERFLOW_ERROR
#endif
; First bank: check for bank-overflow
;#if ($ > 03FFFh)
; BANK_OVERFLOW_ERROR
;#endif
; =============================================================================
.end