-
Notifications
You must be signed in to change notification settings - Fork 0
/
WSHWTest.asm
executable file
·1764 lines (1498 loc) · 40.2 KB
/
WSHWTest.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
;-----------------------------------------------------------------------------
;
; WonderSwan Hardware Test
; by Fredrik Ahlström, 2023-2024
; https://github.com/FluBBaOfWard/WSHWTest
;
; UP/DOWN - Choose option
; A - Start
;
; Assemble with:
; nasm -f bin -o WSHWTest.wsc WSHWTest.asm
;
;-----------------------------------------------------------------------------
ORG 0x0000
CPU 186
BITS 16
SECTION .data
%include "WonderSwan.inc"
MYSEGMENT equ 0xf000
foregroundMap equ WS_TILE_BANK - MAP_SIZE
backgroundMap equ foregroundMap - MAP_SIZE
spriteTable equ backgroundMap - SPR_TABLE_SIZE
soundTable equ spriteTable - 0x40
PSR_S equ 0x80
PSR_Z equ 0x40
PSR_P equ 0x04
MENU_ENTRIES equ 6
SECTION .text
;PADDING 15
initialize:
xor ax, ax
mov ss, ax ; Set SS segment to 0x0000 (RAM).
mov [ss:startRegSP], sp
mov sp, 0x2000
pushf
cli
cld
pop ax
mov [ss:startRegF], ax
; mov [ss:startRegAW], ax
mov [ss:startRegCW], cx
mov [ss:startRegDW], dx
mov [ss:startRegBW], bx
; mov [ss:startRegSP], sp
mov [ss:startRegBP], bp
mov [ss:startRegIX], si
mov [ss:startRegIY], di
mov ax, es
mov [es:startRegDS1], ax
mov ax, cs
mov [es:startRegPS], ax
; mov ax, ss
; mov [es:startRegSS], ax
mov ax, ds
mov [es:startRegDS0], ax
;-----------------------------------------------------------------------------
; Initialize registers and RAM
;-----------------------------------------------------------------------------
mov ax, MYSEGMENT
mov ds, ax
xor ax, ax
mov es, ax ; Set ES segment to 0x0000 (RAM).
; Setup stack
mov bp, ax
mov ss, ax
mov sp, WS_STACK
; Clear Ram
mov di, 0x0120
mov cx, 0x1E70
rep stosw
out IO_SRAM_BANK,al
;-----------------------------------------------------------------------------
; Initialize variables
;-----------------------------------------------------------------------------
mov word [es:globalFrameCounter], 0
mov word [es:lfsr1], 0x0234
mov word [es:lfsr2], 0x1234
;-----------------------------------------------------------------------------
; Initialize video
;-----------------------------------------------------------------------------
in al, SYSTEM_CTRL2
; or al, VMODE_4C | VMODE_CLEANINIT
or al, VMODE_CLEANINIT
out SYSTEM_CTRL2, al
xor ax, ax
mov al, BG_MAP( backgroundMap ) | FG_MAP( foregroundMap )
out IO_SCR_AREA, al
mov al, SPR_AREA( spriteTable )
out IO_SPR_AREA, al
in al, IO_LCD_IF_CTRL
or al, LCD_ON
out IO_LCD_IF_CTRL, al
xor al, al
out IO_LCD_SEG_DATA, al
; Init Sound
mov al,WAVE_RAM(soundTable)
out IO_WAVE_RAM, al
;-----------------------------------------------------------------------------
; Register our interrupt handlers
;-----------------------------------------------------------------------------
mov di, 0*4 ; Division error vector
mov word [es:di], divisionErrorHandler
mov word [es:di + 2], MYSEGMENT
mov di, 1*4 ; Int1
mov word [es:di], int1InstructionHandler
mov word [es:di + 2], MYSEGMENT
mov di, 2*4 ; NMI
mov word [es:di], nmiHandler
mov word [es:di + 2], MYSEGMENT
mov di, 3*4 ; Int3
mov word [es:di], int3InstructionHandler
mov word [es:di + 2], MYSEGMENT
mov di, 4*4 ; BRKV
mov word [es:di], overflowExceptionHandler
mov word [es:di + 2], MYSEGMENT
mov di, 5*4 ; CHKIND
mov word [es:di], boundsExceptionHandler
mov word [es:di + 2], MYSEGMENT
mov di, 6*4 ; Undefined instruction vector
mov word [es:di], undefinedInstructionHandler
mov word [es:di + 2], MYSEGMENT
mov di, 7*4 ; POLL
mov word [es:di], pollExceptionHandler
mov word [es:di + 2], MYSEGMENT
mov di, 0x10*4 ; output char vector
mov word [es:di], outputCharHandler
mov word [es:di + 2], MYSEGMENT
mov ax, INT_BASE ; 0x20
out IO_INT_VECTOR, al
mov di, INTVEC_HBLANK_TIMER
add di, ax
shl di, 2
mov word [es:di], hblankTimerHandler
mov word [es:di + 2], MYSEGMENT
mov di, INTVEC_VBLANK_START
add di, ax
shl di, 2
; mov word [es:di], vblankHandler
mov word [es:di], vblankInterruptHandler
mov word [es:di + 2], MYSEGMENT
mov di, INTVEC_VBLANK_TIMER
add di, ax
shl di, 2
mov word [es:di], vblankTimerHandler
mov word [es:di + 2], MYSEGMENT
mov di, INTVEC_DRAWING_LINE
add di, ax
shl di, 2
mov word [es:di], lineCompareHandler
mov word [es:di + 2], MYSEGMENT
mov di, INTVEC_SERIAL_RECEIVE
add di, ax
shl di, 2
mov word [es:di], serialReceiveHandler
mov word [es:di + 2], MYSEGMENT
mov di, INTVEC_RTC_ALARM
add di, ax
shl di, 2
mov word [es:di], cartridgeIrqHandler
mov word [es:di + 2], MYSEGMENT
mov di, INTVEC_KEY_PRESS
add di, ax
shl di, 2
mov word [es:di], keyPressHandler
mov word [es:di + 2], MYSEGMENT
mov di, INTVEC_SERIAL_SEND
add di, ax
shl di, 2
mov word [es:di], serialTransmitHandler
mov word [es:di + 2], MYSEGMENT
; Clear HBL & Timers
xor ax, ax
out IOw_H_BLANK_TIMER, ax
out IO_TIMER_CTRL, al
; Acknowledge all interrupts
dec al
out INT_CAUSE_CLEAR, al
; Enable VBL interrupt
mov al, INT_VBLANK_START
out IO_INT_ENABLE, al
; We have finished initializing, interrupts can now fire again
sti
;-----------------------------------------------------------------------------
; Copy font tile data into WS's tile mem
;-----------------------------------------------------------------------------
; Copy font tile data to tile bank 1
xor ax,ax
mov si, MonoFont
mov di, WS_TILE_BANK + 16*16*2
mov cx, 8*16*6
monoFontLoop:
lodsb
stosw
loop monoFontLoop
;-----------------------------------------------------------------------------
; Copy font palette into WSC's palette area
;-----------------------------------------------------------------------------
; Copy 2-colour (2 bytes per colour) font palette to
; beginning of palettes area (becoming palette 0)
mov si, FontTilePalette
mov di, WSC_PALETTES
mov cx, 2
rep movsw
mov ax, 0x7f0
out IO_LCD_GRAY_01, ax
mov ax, 0x0010
out IOw_SCR_LUT_0, ax
mov ax, 0x0020
out IOw_SCR_LUT_1, ax
mov ax, 0x0000
out IOw_SCR_LUT_2, ax
mov ax, 0x0000
out IOw_SCR_LUT_4, ax
; Copy sound to RAM
mov si, SoundSamples
mov di, soundTable
mov cx, 0x20
rep movsw
;-----------------------------------------------------------------------------
; Make background map point to our tiles, essentially "painting" the
; background layer with our tiles, coloured as per our palettes
;-----------------------------------------------------------------------------
main:
call clearScreen
call clearForegroundMap
mov si, headLineStr
call writeString
mov si, menuShowRegistersStr
call writeString
mov si, menuTestAllStr
call writeString
mov si, menuTestInterruptStr
call writeString
mov si, menuTestTimersStr
call writeString
mov si, menuTestWindowsStr
call writeString
mov si, menuTestSoundStr
call writeString
mov si, menuPowerOffStr
call writeString
; Turn on display
mov al, BG_ON
out IO_DISPLAY_CTRL, al
;-----------------------------------------------------------------------------
;
; BEGIN main area
;
;-----------------------------------------------------------------------------
mainLoop:
hlt ; Wait until next interrupt
mov bx, [es:keysDown]
; Check player input
; test bl, (PAD_RIGHT<<4)
; jnz speed_up
; test bl, (PAD_LEFT<<4)
; jnz speed_down
mov cl, [es:menuYPos]
test bl, (PAD_UP<<4)
jz dontMoveUp
sub cl, 1
jns dontMoveUp
mov cl, 0
dontMoveUp:
test bl, (PAD_DOWN<<4)
jz dontMoveDown
add cl, 1
cmp cl, MENU_ENTRIES
js dontMoveDown
mov cl, MENU_ENTRIES
dontMoveDown:
mov [es:menuYPos], cl
mov ch, cl
add ch, 1
mov byte [es:cursorXPos], 0
mov [es:cursorYPos], ch
mov al, ' '
int 0x10
add ch, 1
mov byte [es:cursorXPos], 0
mov [es:cursorYPos], ch
mov al, '>'
int 0x10
add ch, 1
mov byte [es:cursorXPos], 0
mov [es:cursorYPos], ch
mov al, ' '
int 0x10
test bl, PAD_A
jz mainLoop
call clearScreen
cmp cl, 0
jz showStartRegs
cmp cl, 1
jz testAll
cmp cl, 2
jz testInterrupt
cmp cl, 3
jz testTimers
cmp cl, 4
jz testWindows
cmp cl, 5
jz testSound
cmp cl, 6
jz powerOffWS
; No input, restart main loop
jmp mainLoop
;-----------------------------------------------------------------------------
;
; END main area
;
;-----------------------------------------------------------------------------
showStartRegs:
call writeStartRegs
call checkKeyInput
jmp main
;-----------------------------------------------------------------------------
testAll:
call testIrq
call testHBlankTimer
call testVBlankTimer
call checkKeyInput
jmp main
;-----------------------------------------------------------------------------
testInterrupt:
call testIrq
call checkKeyInput
jmp main
;-----------------------------------------------------------------------------
testTimers:
call testHBlankTimer
call testVBlankTimer
call checkKeyInput
jmp main
;-----------------------------------------------------------------------------
testWindows:
call testHorizontalWindows
jmp main
;-----------------------------------------------------------------------------
testSound:
call testSoundMixer
jmp main
;-----------------------------------------------------------------------------
powerOffWS:
mov al, 0x80 ; Color mode on
out SYSTEM_CTRL2, al
mov al, 1
out SYSTEM_CTRL3, al
off:
jmp off
;-----------------------------------------------------------------------------
writeStartReg: ; SI string, AX value
;-----------------------------------------------------------------------------
push ax
call writeString
pop ax
call printHexW
mov al, 10
int 0x10
ret
;-----------------------------------------------------------------------------
writeStartRegs:
;-----------------------------------------------------------------------------
mov si, startFStr
mov ax, [es:startRegF]
call writeStartReg
mov si, startAWStr
mov ax, [es:startRegAW]
call writeStartReg
mov si, startCWStr
mov ax, [es:startRegCW]
call writeStartReg
mov si, startDWStr
mov ax, [es:startRegDW]
call writeStartReg
mov si, startBWStr
mov ax, [es:startRegBW]
call writeStartReg
mov si, startBPStr
mov ax, [es:startRegBP]
call writeStartReg
mov si, startSPStr
mov ax, [es:startRegSP]
call writeStartReg
mov si, startIXStr
mov ax, [es:startRegIX]
call writeStartReg
mov si, startIYStr
mov ax, [es:startRegIY]
call writeStartReg
mov si, startDS1Str
mov ax, [es:startRegDS1]
call writeStartReg
mov si, startPSStr
mov ax, [es:startRegPS]
call writeStartReg
mov si, startSSStr
mov ax, [es:startRegSS]
call writeStartReg
mov si, startDS0Str
mov ax, [es:startRegDS0]
call writeStartReg
ret
;-----------------------------------------------------------------------------
; Test Interrupt Manager.
;-----------------------------------------------------------------------------
testIrq:
mov si, testingIrqStr
call writeString
mov si, testingIrq0Str
call writeString
mov byte [es:isTesting], 1
cli
; Disable all interrupts
xor al, al
out IO_INT_ENABLE, al
; Acknowledge all interrupts
dec al
out INT_CAUSE_CLEAR, al
; Setup HBL/VBL Timers
mov ax, 1
out IOw_H_BLANK_TIMER, ax
out IOw_V_BLANK_TIMER, ax
mov al, 0x0F
out IO_TIMER_CTRL, al
mov al, 0x40
out IO_LCD_INTERRUPT, al
; Enable serial
mov al, COMM_ENABLE | COMM_SPEED_38400
out IO_SERIAL_STATUS, al
mov bl,40
call waitLine
mov bl,20
call waitLine
in al, IO_INT_CAUSE
xor al, 0
mov si, failedStr
jnz int0Fail
mov si, okStr
int0Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingIrq1Str
call writeString
; Enable all interrupts
mov al, 0xFF
out IO_INT_ENABLE, al
mov bl,40
call waitLine
mov bl,20
call waitLine
in al, IO_INT_CAUSE
xor al, 0
mov si, failedStr
jz int1Fail
mov si, okStr
int1Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingIrq2Str
call writeString
; Disable all interrupts
xor al, al
out IO_INT_ENABLE, al
mov bl,40
call waitLine
mov bl,20
call waitLine
in al, IO_INT_CAUSE
xor al, 0
mov si, failedStr
jz int2Fail
mov si, okStr
int2Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingIrq3Str
call writeString
; Acknowledge all interrupts
mov al, 0xFF
out INT_CAUSE_CLEAR, al
mov bl,40
call waitLine
mov bl,20
call waitLine
in al, IO_INT_CAUSE
xor al, 0
mov si, failedStr
jnz int3Fail
mov si, okStr
int3Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingIrq4Str
call writeString
; Enable VBL interrupt
mov al, INT_VBLANK_START
out IO_INT_ENABLE, al
mov bl,80
call waitLine
mov bl,60
call waitLine
mov word [es:vblankIrqCount], 0
sti
nop
cli
mov al, [es:vblankIrqCount]
xor al, 0
mov si, failedStr
jz int4Fail
mov si, okStr
int4Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingIrq5Str
call writeString
; Enable VBL interrupt
mov al, INT_VBLANK_START
out IO_INT_ENABLE, al
mov bl,40
call waitLine
mov bl,20
call waitLine
; Disable all interrupts
xor al, al
out IO_INT_ENABLE, al
mov word [es:vblankIrqCount], 0
sti
nop
cli
mov al, [es:vblankIrqCount]
xor al, 0
mov si, failedStr
jz int5Fail
mov si, okStr
int5Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingIrq6Str
call writeString
; Enable VBL interrupt
mov al, INT_VBLANK_START
out IO_INT_ENABLE, al
mov bl,40
call waitLine
mov bl,20
call waitLine
; Acknowledge VBL interrupt
mov al, INT_VBLANK_START
out INT_CAUSE_CLEAR, al
mov word [es:vblankIrqCount], 0
sti
nop
cli
mov al, [es:vblankIrqCount]
xor al, 0
mov si, failedStr
jnz int6Fail
mov si, okStr
int6Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingIrq7Str
call writeString
; Enable HBL interrupt
mov al, INT_HBLANK_TIMER
out IO_INT_ENABLE, al
; Acknowledge all interrupts
mov al, 0xFF
out INT_CAUSE_CLEAR, al
mov bl,40
call waitLine
mov bl,20
call waitLine
mov word [es:hblankTimerIrqCount], 0
sti
nop
nop
cli
mov al, [es:hblankTimerIrqCount]
cmp al, 2
mov si, failedStr
jnz int7Fail
mov si, okStr
int7Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingIrq8Str
call writeString
mov bl,20
call waitLine
; Enable serial
mov al, COMM_ENABLE | COMM_SPEED_38400 | COMM_OVERRUN_RESET
out IO_SERIAL_STATUS, al
; Only enable serial receive interrupt
mov al, INT_SERIAL_RECEIVE
out IO_INT_ENABLE, al
; Acknowledge all interrupts
mov al, 0xFF
out INT_CAUSE_CLEAR, al
mov bl,22
call waitLine
in al, IO_INT_CAUSE
xor al, 0
mov si, failedStr
jnz int8Fail
mov si, okStr
int8Fail:
call writeString
sti
;-----------------------------------------------------------------------------
; Enable VBL interrupt
mov al, INT_VBLANK_START
out IO_INT_ENABLE, al
mov byte [es:isTesting], 0
xor ax, ax
ret
;-----------------------------------------------------------------------------
; Test Timers
;-----------------------------------------------------------------------------
testHBlankTimer:
mov si, testingTimerStr
call writeString
mov si, testingTimer0Str
call writeString
mov byte [es:isTesting], 1
cli
; Disable all interrupts
xor al, al
out IO_INT_ENABLE, al
; Acknowledge all interrupts
dec al
out INT_CAUSE_CLEAR, al
mov bl, 20
call waitLine
; Setup HBL Timer
mov ax, 0
out IOw_H_BLANK_TIMER, ax
mov al, 0x03
out IO_TIMER_CTRL, al
mov bl, 80
call waitLine
in ax, IOw_H_BLANK_COUNTER
xor ax, 0
mov si, failedStr
jnz timer0Fail
mov si, okStr
timer0Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingTimer1Str
call writeString
mov bl, 20
call waitLine
; Setup HBL Timer
mov al, 0x00
out IO_TIMER_CTRL, al
mov ax, 300
out IOw_H_BLANK_TIMER, ax
mov bl, 80
call waitLine
in ax, IOw_H_BLANK_COUNTER
cmp ax, 300
mov si, failedStr
jnz timer1Fail
mov si, okStr
timer1Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingTimer2Str
call writeString
mov bl, 20
call waitLine
; Setup HBL Timer
mov ax, 300
out IOw_H_BLANK_TIMER, ax
mov al, 0x03
out IO_TIMER_CTRL, al
mov bl, 80
call waitLine
in ax, IOw_H_BLANK_COUNTER
cmp ax, 241
mov si, failedStr
jge timer2Fail
mov si, okStr
timer2Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingTimer3Str
call writeString
mov bl, 20
call waitLine
; Setup HBL Timer
mov ax, 300
out IOw_H_BLANK_TIMER, ax
mov al, 0x01
out IO_TIMER_CTRL, al
mov bl, 80
call waitLine
in ax, IOw_H_BLANK_COUNTER
cmp ax, 241
mov si, failedStr
jge timer3Fail
mov si, okStr
timer3Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingTimer4Str
call writeString
mov bl, 20
call waitLine
; Setup HBL Timer
mov ax, 300
out IOw_H_BLANK_TIMER, ax
mov al, 0x02
out IO_TIMER_CTRL, al
mov bl, 80
call waitLine
in ax, IOw_H_BLANK_COUNTER
cmp ax, 300
mov si, failedStr
jnz timer4Fail
mov si, okStr
timer4Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingTimer5Str
call writeString
mov bl, 20
call waitLine
; Setup HBL Timer
mov ax, 300
out IOw_H_BLANK_TIMER, ax
mov al, 0x01
out IO_TIMER_CTRL, al
mov bl, 40
call waitLine
; Turn off timer
xor al, al
out IO_TIMER_CTRL, al
mov bl, 60
call waitLine
; Turn it on again
mov al, 0x01
out IO_TIMER_CTRL, al
mov bl, 100
call waitLine
in ax, IOw_H_BLANK_COUNTER
cmp ax, 239
mov si, failedStr
jl timer5Fail
mov si, okStr
timer5Fail:
call writeString
;-----------------------------------------------------------------------------
mov si, testingTimer6Str
call writeString
; Turn off timer
xor al, al
out IO_TIMER_CTRL, al
; Acknowledge HBl interrupt
mov al, INT_HBLANK_TIMER
out INT_CAUSE_CLEAR, al
; Enable HBl interrupt
mov al, INT_HBLANK_TIMER
out IO_INT_ENABLE, al
mov bl, 20
call waitLine
; Setup HBL Timer
mov ax, 1
out IOw_H_BLANK_TIMER, ax
mov bl, 22
call waitLine
in al, IO_INT_CAUSE
xor al, INT_HBLANK_TIMER
mov si, failedStr
jnz timer6Fail
mov si, okStr
timer6Fail:
call writeString
mov al, INT_VBLANK_START
out IO_INT_ENABLE, al
sti
ret
;-----------------------------------------------------------------------------
testVBlankTimer:
; Enable VBL interrupt
mov al, INT_VBLANK_START
out IO_INT_ENABLE, al
mov byte [es:isTesting], 0
mov al, 10
int 0x10
xor ax, ax
ret
;-----------------------------------------------------------------------------
testHorizontalWindows:
; Turn on display
mov al, BG_ON | FG_ON | FG_WIN_ON
out IO_DISPLAY_CTRL, al
mov di, backgroundMap + ((4 * MAP_TWIDTH) + 13) * 2
mov ax, BG_CHR( 0x7F, 0, 0, 0, 0 ) ; BG_CHR(tile,pal,bank,hflip,vflip)
stosw
stosw
mov di, backgroundMap + ((5 * MAP_TWIDTH) + 12) * 2
mov ax, BG_CHR( 0x7F, 0, 0, 0, 0 ) ; BG_CHR(tile,pal,bank,hflip,vflip)
stosw
stosw