-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path9958driver.asm
1467 lines (1242 loc) · 34.3 KB
/
9958driver.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
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;port #0 VRAM Data (R/W) $A020
;port #1 Status register (R) / VRAM Address (W) / Register set-up (W) $A021
;port #2 Palette registers (W) $A022
;port #3 Register indirect addressing (W)
;$2FFE - used for draw rectangle filled function
initializeVideo:
call clearVram
call VdpCharsIntoRam
call setupDefaultColors
;set up palette register with 4 colors
;ld a, 0
;ld d, %00000000 ;green
;ld e, %00000111
;call VdpWriteToPaletteRegister
;ld a, 1
;ld d, %00000111
;ld e, %00000000 ;blue
;call VdpWriteToPaletteRegister
;ld a, 2
;ld d, %01110111
;ld e, %00000111 ;white
;call VdpWriteToPaletteRegister
;ld a, 3
;ld d, %00000000
;ld e, %00000000 ;black
;call VdpWriteToPaletteRegister
;setup text mode 1
;register 0
ld d, %00000100 ;change to %00000100 for text2. %00000000
ld a, 0
call VdpWriteToStandardRegister
;set up register 1
ld d, %01010000
ld a, 1
call VdpWriteToStandardRegister
;set up register 8
;ld d, %00101000
;ld a, 8
;call VdpWriteToStandardRegister
;set up register 9
;ld d, %00000000 ;dot clock in "output" mode. s1 and s0 "simultaneous mode" (Whatever that means) set to zero
;ld a, 9
;call VdpWriteToStandardRegister
ld d, %11110000 ;do it again just to make sure
ld a, 7
call VdpWriteToStandardRegister
;set up register 12 and configure cursor color in text 2 mode
ld d, %00001010
ld a, 12
call VdpWriteToStandardRegister
;configure register 13, the cursor blink time register
ld d, %01000100
ld a, 13
call VdpWriteToStandardRegister
;set values of pattern generator, pattern layout and pattern color table
;I am using "MSX system default" values
;text 2 pattern generator: 01000h-017FFh. Pattern layout: 00000h-0077Fh (00000h-0086Fh in 26.5 line mode). Pattern color table 800h-8EFh (800h-90Dh in 26.5 mode)
ld d, %00000011
ld a, 2
call VdpWriteToStandardRegister
ld d, %00000010
ld a, 4
call VdpWriteToStandardRegister
ld d, %00100111
ld a, 3
call VdpWriteToStandardRegister
ld d, %00000000
ld a, 10
call VdpWriteToStandardRegister
;do this after loading registers in case its needed or something
call writeRegisterOne
;set vram to pos 0
ld a, 14
ld d, %00000000 ;bits a16, a15 and a14
call VdpWriteToStandardRegister
;pro-gamer move: since register b and c got set in the prev function, i'm not setting them again
ld a, %00000000 ;bits a0-a7
out (c), a
ld a, %00000000 ;bits a8-a13. bit 6 is r/w. bit 7 should stay zero
out (c), a
;put a visual confirmation on the lcd that this function finished
ld a, %11000000 ;the lcd's address for the 2nd line
call lcdBlankLine ;print a blank line on the 2nd line on the lcd to discard any data from the previous command
ld hl, donemsg
call printString
call backToPrevCursorPos
ret
;sets up and configures graphics 4 mode
; pattern layout (bitmap): 00000h-069ffh
; sprite patterns 07800h-07fffh
; sprite attributes 07600h-0767Ffh
; sprite colors 07400h-075ffh
setupG4Mode:
;put the vdp into graphics mode 4. m5 = 0. m4 = 1. m3 = 1. m2 = 0. m1 = 0
;register 0
ld d, %00000110 ;change to %00000100 for text2. %00000000
ld a, 0
call VdpWriteToStandardRegister
;set up register 1
ld d, %01000000
ld a, 1
call VdpWriteToStandardRegister
;set up register 8
ld d, %00001000
ld a, 8
call VdpWriteToStandardRegister
;set register 23 to zero
ld d, 0
ld a, 23
call VdpWriteToStandardRegister
call clearMostVram
;here's what I need to set:
; pattern layout (bitmap): 00000h-069ffh
; sprite patterns 07800h-07fffh
; sprite attributes 07600h-0767Ffh
; sprite colors 07400h-075ffh
;pattern layout table
ld d, %00011111
ld a, 2
call VdpWriteToStandardRegister
;sprite patterns
ld d, %00001111
ld a, 6
call VdpWriteToStandardRegister
;sprite attributes high
ld d, %00000000
ld a, 11
call VdpWriteToStandardRegister
;sprite attributes low ($7600)
ld d, %11101111
ld a, 5
call VdpWriteToStandardRegister
;sprite color table high
ld d, %00000001
ld a, 10
call VdpWriteToStandardRegister
;sprite color table low
ld d, %11010000
ld a, 3
call VdpWriteToStandardRegister
ret
;sets the color palette to the default
;I'm making it the same as the Microsoft Windows default 16-color palette
;https://en.wikipedia.org/wiki/List_of_software_palettes#Microsoft_Windows_default_16-color_palette
setupDefaultColors:
;color 0 = black
ld a, 0
ld d, 0
ld e, 0
call VdpWriteToPaletteRegister
;color 1 = maroon
ld a, 1
ld d, %01000000
ld e, %00000000
call VdpWriteToPaletteRegister
;color 2 = dark green
ld a, 2
ld d, %00000000
ld e, %00000100
call VdpWriteToPaletteRegister
;color 3 = poop brown
ld a, 3
ld d, %01000000
ld e, %00000100
call VdpWriteToPaletteRegister
;color 4 = navy blue
ld a, 4
ld d, %00000100
ld e, %00000000
call VdpWriteToPaletteRegister
;color 5 = purple
ld a, 5
ld d, %01000100
ld e, %00000000
call VdpWriteToPaletteRegister
;color 6 = teal
ld a, 6
ld d, %00000100
ld e, %00000100
call VdpWriteToPaletteRegister
;color 7 = silver
ld a, 7
ld d, %01000100
ld e, %00000100
call VdpWriteToPaletteRegister
;color 8 = gray
ld a, 8
ld d, %00100010
ld e, %00000010
call VdpWriteToPaletteRegister
;color 9 = red
ld a, 9
ld d, %01110000
ld e, %00000000
call VdpWriteToPaletteRegister
;color 10 = bright green
ld a, 10
ld d, %00000000
ld e, %00000111
call VdpWriteToPaletteRegister
;color 11 = yellow
ld a, 11
ld d, %01110000
ld e, %00000111
call VdpWriteToPaletteRegister
;color 12 = blue
ld a, 12
ld d, %00000111
ld e, %00000000
call VdpWriteToPaletteRegister
;color 13 = fuchsia
ld a, 13
ld d, %01110111
ld e, %00000000
call VdpWriteToPaletteRegister
;color 14 = aqua
ld a, 14
ld d, %00000111
ld e, %00000111
call VdpWriteToPaletteRegister
;color 15 = white
ld a, 15
ld d, %01110111
ld e, %00000111
call VdpWriteToPaletteRegister
ret
;reads status from whatever status register number the a register contains
VdpReadStatus:
;write contents of a register to vdp register 15 (should be 0-9)
;ld hl, $A021
;ld (hl), a
ld b, $A0
ld c, $21
out (c), a
ld a, 15 + 128
out (c), a
;it shoud now be set up to read the status of the inputted register
in a, (c)
ret
;d should contain register data
;a should contain register number
VdpWriteToStandardRegister:
ld b, $A0
ld c, $21
;write the data byte first because that's just what you do
out (c), d
;write the register number next
;add a, 128
or %10000000 ;different way of adding 128 to a
out (c), a
ret
; a register needs to contain palette register number you want to write to (0-15)
; d register needs to contain first palette byte
; e register needs to contain second palette byte
;note that the pointer value in register 16 auto increments each time you do this
VdpWriteToPaletteRegister:
push af
push de
ld d, a
ld a, 16
call VdpWriteToStandardRegister
pop de
pop af
ld b, $A0
ld c, $22
out (c), d
out (c), e
ret
;text 2 pattern generator: 01000h-017FFh. Pattern layout: 00000h-0077Fh (00000h-0086Fh in 26.5 line mode)
VdpCharsIntoRam:
ld a, 14
ld d, %00000000 ;bits a16, a15 and a14
call VdpWriteToStandardRegister
;pro-gamer move: since register b and c got set in the prev function, i'm not setting them again
ld a, %00000000 ;bits a0-a7
out (c), a
ld a, %00010001 ;bits a8-a13. bit 6 is r/w. bit 7 should stay zero
out (c), a
;now, time to make a bigass loop
;get ready to start writing to port 0 - the vram access port
ld b, $A0
ld c, $20
ld hl, letters_space
ld a, (hl)
VdpCharsIntoRamLoopStart:
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
out (c), a
inc hl
ld a, (hl)
cp %11111111
jr nz, VdpCharsIntoRamLoopStart
ret
;copy whatever's in register a to next address in vram
;changed registers: a, b, c and hl
VdpPrintChar:
ld b, $A0
ld c, $20
out (c), a
;update the column counter
ld hl, $9EFA
ld a, (hl)
inc a
ld (hl), a
cp 80
jr nc, incRow
jr VdpPrintCharExit
;if more than 80 columns, set column numbers to 0 and increment row number
incRow:
ld a, 0
ld (hl), a
ld hl, $9EFB
ld a, (hl)
inc a
ld (hl), a
VdpPrintCharExit:
ret
;hl should contain memory address of the string to print
;print a string using the VdpPrintChar subroutine
VPrintString:
push hl
call RowsColumnsToVram
pop hl
ld a, (hl)
;==========================
;push hl
;call VdpPrintChar ;load the first character of every string twice so I can see wtf it's really doing when it copies over that other pointless garbage
;;pop hl
;==========================
VPrintStringLoop:
push hl
call VdpPrintChar
pop hl
inc hl
ld a, (hl)
cp 0
jr nz, VPrintStringLoop
ret
VdpNewLine:
ld hl, $9EFB ;increase row by 1
ld a, (hl)
inc a
ld (hl), a
ret
VdpCarriageReturn:
ld hl, $9EFA ;reset column to 0
ld a, 0
ld (hl), a
ret
VdpInsertEnter:
call VdpNewLine
call VdpCarriageReturn
call checkScreenSize
call RowsColumnsToCursorPos
call RowsColumnsToVram
ret
VdpBackspace:
ld hl, $9EFA
ld a, (hl)
cp 0
jr z, VdpBackspaceExit ;if the current column is zero, you can't backspace any further
dec a
ld (hl), a
;let's nullify the latest command buffer byte before resetting the command character count
ld hl, $2009
ld c, (hl)
push bc
ld hl, $2010
ld b, 0
add hl, bc
pop bc
ld a, 0
ld (hl), a
dec hl
ld (hl), a ;you have to do this twice or else it will only delete the character + 1 position to the right of where you backspace
ld hl, $2009
ld a, (hl)
dec a
ld (hl), a
call RowsColumnsToVram
;now put in a nullspace without updating command buffer counter then vram backspace again
ld a, 0
call VdpPrintChar
;a whitespace has now been written, graphically backspacing the thing that the user backspaced
ld hl, $9EFA
ld a, (hl)
dec a
ld (hl), a
call RowsColumnsToCursorPos
call RowsColumnsToVram
VdpBackspaceExit:
ret
VdpInsertTab:
;insert code here
ld hl, $9EFA ;get the horizontal cursor pos
ld c, (hl)
ld d, 8
;divide number of columns by 8 to obtain the remainder
call CDivD
ld b, a
ld a, 8
;do 8-remainder. this gets the number of spaces that need to be inserted in order to perform a correct tab operation
sub b
ld d, a
VdpInsertTabSpaceLoop:
ld a, " "
call VdpPrintChar
dec d
ld a, d
cp 0
jr nz, VdpInsertTabSpaceLoop
call RowsColumnsToCursorPos
call RowsColumnsToVram
;there that should be it
ret
;sets vram registor address to something that matches the rows/column bytes
RowsColumnsToVram:
ld a, 14
ld d, 0
call VdpWriteToStandardRegister
ld hl, $9EFB
ld a, (hl)
ld d, 0
ld e, 80
call DE_Times_A
ex de, hl
ld hl, $9EFA
ld c, (hl)
ld b, 0
ex de, hl
add hl, bc
ld b, $A0
ld c, $21
out (c), l
res 7, h
set 6, h
out (c), h
ret
RowsColumnsToCursorPos:
call eraseCursorTable
ld a, 14
ld d, 0
call VdpWriteToStandardRegister
ld hl, $9EFB ;rows
ld a, (hl)
ld d, 0
ld e, 10
call DE_Times_A
ex de, hl
push de
ld hl, $9EFA ;columns
ld c, (hl)
ld b, 0
ld d, 8
call CDivD
pop de
ex de, hl
add hl, bc
ld bc, $0800 ;the additional offset to get the vram address pointer into the cursor sector
add hl, bc
;we now have the address
ld b, $A0
ld c, $21
out (c), l
res 7, h
set 6, h
out (c), h
;now, prepare the data bit
ld c, $80
cp 0
jr z, byPassRemainder
remainderLoop:
srl c
dec a
cp 0
jr nz, remainderLoop
byPassRemainder:
ld a, c
ld c, $20
out (c), a
ret
;clear first 8kb of vram
clearVram:
ld a, 14
ld d, 0
call VdpWriteToStandardRegister
ld c, $20
ld a, 0
out (c), a
add a, 64
out (c), a
ld hl, $2000 ;clear the first 8kb of vram
ld e, 0
clearContinue:
out (c), e
dec hl
ld a, h
or l
nop
nop
jr nz, clearContinue
ret
;clear first 32kb of vram
clearMostVram:
ld a, 14
ld d, 0
call VdpWriteToStandardRegister
ld c, $20
ld a, 0
out (c), a
add a, 64
out (c), a
ld hl, $8000 ;clear the first 8kb of vram
ld e, 0
clearMostVramContinue:
out (c), e
dec hl
ld a, h
or l
nop
nop
jr nz, clearMostVramContinue
ret
eraseScreen:
;a slow but low-memory way of getting all the registers ready and vram pointer in the correct spot
call RowsColumnsToVram
ld hl, $77F ;erase 1920 characters- the entire space of a 80x24 char screen could probably change that to $860 so it'll work in 26.5x80 mode but i haven't tried it yet)
ld c, $20
ld e, 0
eraseScreenContinue:
out (c), e
dec hl
ld a, h
or l
nop
nop
jr nz, eraseScreenContinue
ret
eraseCursorTable:
ld a, 14
ld d, 0
call VdpWriteToStandardRegister
ld d, 0
out (c), d
ld d, %01001000
out (c), d
ld hl, $00FE
ld c, $20
ld e, 0
eraseCursorTableContinue:
out (c), e
dec hl
ld a, h
or l
nop
nop
jr nz, eraseCursorTableContinue
ret
;because a guy on a forum said setting bit 6 of register 1 for screen on after any register command might work
writeRegisterOne:
ld b, $A0
ld c, $21
;set up register 1
ld d, %01010000
ld a, 1
call VdpWriteToStandardRegister
ret
;move screen up 2 rows
shiftScreenUp:
ld a, 14
ld d, 0
call VdpWriteToStandardRegister
ld d, %10100000
out (c), d
ld d, %00000000
out (c), d
;now that the vram address pointer is at position $A0 - 160 characters away from the start, start copying contents to ram
;it is faster to copy all this stuff to ram first then copy it back to vram than it is to copy a single value from vram, paste it 1 address lower and do that over and over (due to the way the address pointer increments)
ld hl, $96F0
ld de, $06DF ;(77F-A0) = the size of the text in vram in text mode 2 - the upper 2 rows
ld c, $20 ;the correct port number for vram since the previous subroutine left it at $21
shiftScreenUpCopyToRam:
in a, (c)
ld (hl), a
inc hl
dec de
ld a, d
or e
jr nz, shiftScreenUpCopyToRam
;don't forget to decrease the row byte by 2 before going into erase screen
ld hl, $9EFB
ld a, (hl)
sub a, 2
ld (hl), a
;all the characters except for the top 2 rows should now be in ram
call eraseScreen ;run the erase screen subroutine
ld a, 14
ld d, 0
call VdpWriteToStandardRegister
ld d, %00000000
out (c), d
ld d, %01000000
out (c), d
ld hl, $96F0 ;the starting ram address where the relevant vram data is temporarily stored
ld de, $06DF ;(77F-A0) = the size of the text in vram in text mode 2 - the upper 2 rows
ld c, $20 ;the correct port number for vram since the previous subroutine left it at $21
shiftScreenUpCopyToVram:
ld a, (hl)
out (c), a
inc hl
dec de
ld a, d
or e
jr nz, shiftScreenUpCopyToVram
ret
;running this will run the shiftScreenUp subroutine if the cursor is on the lowest row
checkScreenSize:
ld hl, $9EFB
ld a, (hl)
cp 24
jr c, checkScreenSizeExit ;if colum row < 24, don't shift the screen up
call shiftScreenUp
checkScreenSizeExit:
ret
;this draws a line onto page 0 while in graphics 4 mode
;b = xpos start. c = ypos start.
;d = xpos end. e = ypos end
;a = color index
drawLine:
push af
ex de, hl
push hl
push bc
;set x starting point of line
ld d, b
ld a, 36
call VdpWriteToStandardRegister
ld d, %00000000
ld a, 37
call VdpWriteToStandardRegister
pop bc
push bc
;set y starting point of line
ld d, c
ld a, 38
call VdpWriteToStandardRegister
ld d, %00000000
ld a, 39
call VdpWriteToStandardRegister
pop bc
pop hl
;if d is greater than b, I want d to become the result of d-b
;otherwise, I want d to become the result of b-d
ex de, hl
ld hl, $0000
ld a, d
cp b
jr nc, dIsGreater
jr bIsGreater
dIsGreater:
sub b
ld d, a
;x transfer diretion = right. Therefore there is no need to change the x transfer direction bit
jr firstComparisonGTFO
bIsGreater:
ld a, b
sub d
ld d, a
;x transfer direction = left
ld a, l
or %00000100
ld l, a
firstComparisonGTFO:
ld a, e
cp c
jr nc, eIsGreater
jr cIsGreater
eIsGreater:
sub c
ld e, a
;y transfer direction = down. Therefore there is no need to change the y transfer direction bit
jr secondComparisonGTFO
cIsGreater:
ld a, c
sub e
ld e, a
;y transfer direction = up
ld a, l
or %00001000
ld l, a
secondComparisonGTFO:
;de should now contain x length and y length
;now I need to figure out which one to assign to long side and low side
;I also don't need the contents of bc anymore. bc can now be used for variable storage or whatever
ld a, d
cp e
jr nc, dIsLongSide
jr eIsLongSide
dIsLongSide:
ld c, e
ld b, d
jr thirdComparisonGTFO
eIsLongSide:
ld c, d
ld b, e
ld a, l
or %00000001
ld l, a
thirdComparisonGTFO:
push hl
push bc
;set long side dots num
ld d, b
ld a, 40
call VdpWriteToStandardRegister
ld d, %00000000
ld a, 41
call VdpWriteToStandardRegister
pop bc
;set short side dots num
ld d, c
ld a, 42
call VdpWriteToStandardRegister
ld d, %00000000
ld a, 43
call VdpWriteToStandardRegister
pop hl
pop af
push hl
;set line color
ld d, a
ld a, 44
call VdpWriteToStandardRegister
pop hl
;set register 45
ld d, l
ld a, 45
call VdpWriteToStandardRegister
;define logical operation - %01110000 for line command
ld d, %01110000
ld a, 46
call VdpWriteToStandardRegister
ret
;waits until the vdp is finished with a command by checking CE bit (bit 0) of status register S#2
waitVdpCommandFinished:
ld d, 2
ld a, 15
call VdpWriteToStandardRegister
ld c, $21
in a, (c)
and %00000001
cp 0
jr nz, waitVdpCommandFinished
ret
;draws a non-filled in rectangle.
;b = x position of rectangle start
;c = y position of recangle start
;d = size x of rectangle
;e = size y of rectangle
;a = color index
drawRectangle:
;draw top line
push bc
push de
push af
ld l, a
ld a, d
add a, b
ld d, a
ld e, c
ld a, l
call drawLine
call waitVdpCommandFinished
pop af
pop de
pop bc
;draw bottom line
push bc
push de
push af
ld l, a
ld a, d
add a, b
ld d, a
ld a, e
add a, c
ld e, a
ld c, a
ld a, l
call drawLine
call waitVdpCommandFinished
pop af
pop de
pop bc
;draw leftmost line
push bc
push de
push af
ld l, a
ld d, b
ld a, c
add a, e
ld e, a
ld a, l
call drawLine
call waitVdpCommandFinished
pop af
pop de