-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphase4_24L-0724.asm
More file actions
1227 lines (1226 loc) · 23.4 KB
/
phase4_24L-0724.asm
File metadata and controls
1227 lines (1226 loc) · 23.4 KB
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
[org 0x0100]
mov ax, 3508h
int 21h
mov word [old_isr], bx
mov word [old_isr+2], es
jmp start
; ==========================================================
; === MULTITASKING MUSIC KERNEL (INTERRUPT HANDLER) ===
; ==========================================================
; Variable to store the original BIOS timer interrupt address
old_isr: dd 0
; Timer logic variables
music_tick_count: dw 0 ; Counts down ticks until next note
note_index: dw 0 ; Current position in the song
current_music: dw music_menu
; Music Data: [Frequency (Hz), Duration (ticks)]
; 0 = Silence/Rest
; -1 = End of Song (Loop)
music_menu:
dw 523, 3 ; C5
dw 392, 3 ; G4
dw 330, 3 ; E4
dw 440, 3 ; A4
dw 494, 3 ; B4
dw 440, 3 ; A4
dw 392, 6 ; G4
dw 0, 2 ; Rest
dw 523, 3 ; C5
dw 392, 3 ; G4
dw 330, 3 ; E4
dw 440, 3 ; A4
dw 494, 3 ; B4
dw 440, 3 ; A4
dw 392, 6 ; G4
dw 0, 6 ; Rest
dw -1, -1 ; Loop
music_game:
dw 440, 2 ; A4
dw 494, 2 ; B4
dw 523, 2 ; C5
dw 587, 2 ; D5
dw 659, 2 ; E5
dw 698, 2 ; F5
dw 784, 2 ; G5
dw 880, 2 ; A5
dw 0, 2 ; Rest
dw 880, 2 ; A5
dw 784, 2 ; G5
dw 698, 2 ; F5
dw 659, 2 ; E5
dw 587, 2 ; D5
dw 523, 2 ; C5
dw 494, 2 ; B4
dw 440, 2 ; A4
dw 0, 2 ; Rest
dw -1, -1 ; Loop
; ------------------------------------------------------------------
; ISR: Interrupt Service Routine (Background Process)
; This runs automatically every 55ms
; ------------------------------------------------------------------
timer_isr:
pusha ; Save all general registers
push ds ; Save Data Segment
push es ; Save Extra Segment
mov ax, cs ; Ensure DS points to our code/data
mov ds, ax
; --- 1. Decrement Duration Counter ---
cmp word [music_tick_count], 0
jg dec_timer ; If > 0, just decrement and exit
jmp load_next_note ; If <= 0, time to change note
dec_timer:
dec word [music_tick_count]
jmp chain_interrupt
load_next_note:
; --- 2. Load Note from Array ---
mov si, [note_index]
mov bx, [current_music]
mov ax, [bx + si] ; Read Frequency
cmp ax, -1 ; Check for Loop Terminator
je reset_song
mov cx, [bx + si + 2] ; Read Duration
mov [music_tick_count], cx
add word [note_index], 4 ; Advance index (2 bytes freq + 2 bytes dur)
; --- 3. Check for Silence ---
cmp ax, 0
je silence_speaker
; --- 4. Play Sound (PIT Hardware Manipulation) ---
; Frequency Divisor = 1193180 / Frequency
mov dx, 0x0012
mov ax, 0x34DC ; DX:AX = 1,193,180
mov cx, [bx + si] ; Get Frequency again
div cx ; AX = Divisor result
mov bx, ax ; Save divisor in BX
; Send Command to PIT (Port 43h)
mov al, 0xB6 ; Channel 2, LSB+MSB, Square Wave
out 0x43, al
; Send Frequency Divisor to PIT (Port 42h)
mov ax, bx
out 0x42, al ; Send Low Byte
mov al, ah
out 0x42, al ; Send High Byte
; Enable Speaker (Port 61h)
in al, 0x61
or al, 00000011b ; Set bits 0 and 1 (Gate + Data)
out 0x61, al
jmp chain_interrupt
silence_speaker:
in al, 0x61
and al, 11111100b ; Clear bits 0 and 1
out 0x61, al
jmp chain_interrupt
reset_song:
mov word [note_index], 0 ; Reset index to 0
mov word [music_tick_count], 1 ; Trigger load immediately
jmp chain_interrupt
chain_interrupt:
pop es ; Restore segments
pop ds
popa ; Restore registers
; IMPORTANT: Jump to original BIOS handler
; This allows Int 1Ah (Timer Tick) to keep working for the game speed
jmp far [cs:old_isr]
; ------------------------------------------------------------------
; SETUP: Hook the Interrupt
; ------------------------------------------------------------------
hook_timer:
push ax
push bx
push ds
mov dx, timer_isr ; Offset of our ISR
mov ax, cs
mov ds, ax
mov ax, 0x2508 ; Set Interrupt Vector
int 0x21
pop ds
pop bx
pop ax
ret
; ------------------------------------------------------------------
; CLEANUP: Restore the Interrupt
; ------------------------------------------------------------------
unhook_timer:
push ax
push dx
push ds
; Turn off speaker immediately
in al, 0x61
and al, 11111100b
out 0x61, al
; Restore original vector
mov dx, [old_isr]
mov ds, [old_isr+2]
mov ax, 0x2508
int 0x21
pop ds
pop dx
pop ax
ret
; ============ MENU SYSTEM ============
draw_background:
push ax
push bx
push cx
push dx
push di
push si
; 1. Fill screen with green grass
mov ax,0xb800
mov es,ax
mov di,0
mov cx,2000
mov ax,0x2020 ; green solid
rep stosw
; ============ STATIC TREE PLANTING ============
; --- ZONE 1: TOP FOREST (Row 4) ---
; Trees sit on row 4 (foliage goes up to row 0)
mov cx, 12 ; Draw 12 trees across the top
mov dx, 2 ; Start at column 2
top_forest_loop:
push 4 ; Row 4
push dx ; Column
call make_tree
add dx, 7 ; Move 7 spaces right
loop top_forest_loop
; --- ZONE 2: BOTTOM FOREST (Rows 21 & 24) ---
; Row 21
mov cx, 12
mov dx, 4 ; Start offset
bot_forest_1:
push 21
push dx
call make_tree
add dx, 7
loop bot_forest_1
; Row 24 (The very bottom edge)
mov cx, 12
mov dx, 2
bot_forest_2:
push 24
push dx
call make_tree
add dx, 7
loop bot_forest_2
; --- ZONE 3: LEFT FLANK (Rows 9, 13, 17) ---
; We draw two columns of trees on the left side
; Row 9
push 9 ; Row
push 3 ; Col
call make_tree
push 9
push 10
call make_tree
; Row 13
push 13
push 5 ; Staggered
call make_tree
push 13
push 12
call make_tree
; Row 17
push 17
push 3
call make_tree
push 17
push 10
call make_tree
; --- ZONE 4: RIGHT FLANK (Rows 9, 13, 17) ---
; We draw two columns of trees on the right side
; Row 9
push 9
push 70
call make_tree
push 9
push 77
call make_tree
; Row 13
push 13
push 68 ; Staggered
call make_tree
push 13
push 75
call make_tree
; Row 17
push 17
push 70
call make_tree
push 17
push 77
call make_tree
; ============ DRAW THE MENU BOX (Unchanged) ============
box_top equ 5
box_bottom equ 19
box_left equ 15
box_right equ 65
; Draw top border
mov bl,box_top
mov al,80
mul bl
add ax,box_left
shl ax,1
mov di,ax
mov cx, box_right - box_left +1
mov ax,0x66DB ; brown solid
rep stosw
; Draw bottom border
mov bl,box_bottom
mov al,80
mul bl
add ax,box_left
shl ax,1
mov di,ax
mov cx, box_right - box_left +1
mov ax,0x66DB
rep stosw
; Draw left border
mov cx, box_bottom - box_top -1
mov bl,box_top +1
left_border_loop:
mov al,80
mul bl
add ax,box_left
shl ax,1
mov di,ax
mov word [es:di],0x66DB
inc bl
loop left_border_loop
; Draw right border
mov cx, box_bottom - box_top -1
mov bl,box_top +1
right_border_loop:
mov al,80
mul bl
add ax,box_right
shl ax,1
mov di,ax
mov word [es:di],0x66DB
inc bl
loop right_border_loop
; Clear inside the box to black
mov cx, box_bottom - box_top -1
mov bl,box_top +1
clear_inner_loop:
mov al,80
mul bl
add ax,box_left +1
shl ax,1
mov di,ax
push cx
mov cx, box_right - box_left -1
mov ax,0x0020 ; black space
rep stosw
pop cx
inc bl
loop clear_inner_loop
pop si
pop di
pop dx
pop cx
pop bx
pop ax
ret
draw_menu:
push ax
push bx
push cx
push dx
push di
push si
call draw_background
; Draw simple title
mov di, (box_top +1) *160 + box_left*2
mov si,title_text
mov cx,14
mov ah,0xCE
call draw_centered_in_box
; Draw options inside the box
mov di, (box_top +4) *160 + box_left*2
mov si,play_text
mov cx,20
mov ah,0x2F
call draw_centered_in_box
mov di, (box_top +6) *160 + box_left*2
mov si,instructions_text
mov cx,24
mov ah,0x1F
call draw_centered_in_box
mov di, (box_top +8) *160 + box_left*2
mov si,credits_text
mov cx,19
mov ah,0x6F ; white on brown
call draw_centered_in_box
mov di, (box_top +10) *160 + box_left*2
mov si,quit_text
mov cx,15
mov ah,0x4F
call draw_centered_in_box
pop si
pop di
pop dx
pop cx
pop bx
pop ax
ret
show_instructions:
push ax
push bx
push cx
push dx
push di
push si
call draw_background
; Draw title
mov di,(box_top +1) *160 + box_left*2
mov si,instructions_title
mov cx,17
mov ah,0x9E ; yellow on blue
call draw_centered_in_box
; Draw instructions
mov di,(box_top +3) *160 + box_left*2
mov si,instr1
mov cx,37
mov ah,0x0F ; white on black
call draw_centered_in_box
mov di,(box_top +4) *160 + box_left*2
mov si,instr2
mov cx,31
mov ah,0x0F
call draw_centered_in_box
mov di,(box_top +5) *160 + box_left*2
mov si,instr3
mov cx,30
mov ah,0x0F
call draw_centered_in_box
mov di,(box_top +6) *160 + box_left*2
mov si,instr4
mov cx,29
mov ah,0x0F
call draw_centered_in_box
mov di,(box_top +7) *160 + box_left*2
mov si,instr5
mov cx,27
mov ah,0x0F
call draw_centered_in_box
; Draw return prompt
mov di,(box_bottom -3) *160 + box_left*2
mov si,return_text
mov cx,28
mov ah,0x2F ; white on green
call draw_centered_in_box
instr_wait:
mov ah,0
int 0x16 ; wait for key
cmp al,0x1B ; ESC key
je instr_exit
cmp al,'m'
je instr_exit
cmp al,'M'
je instr_exit
jmp instr_wait
instr_exit:
pop si
pop di
pop dx
pop cx
pop bx
pop ax
ret
show_credits:
push ax
push bx
push cx
push dx
push di
push si
call draw_background
; Draw title
mov di,(box_top +1) *160 + box_left*2
mov si,credits_title
mov cx,7
mov ah,0x9E
call draw_centered_in_box
; Draw names
mov di,(box_top +3) *160 + box_left*2
mov si,name1
mov cx,22
mov ah,0x0F
call draw_centered_in_box
mov di,(box_top +4) *160 + box_left*2
mov si,name2
mov cx,19
mov ah,0x0F
call draw_centered_in_box
; Draw return prompt
mov di,(box_bottom -3) *160 + box_left*2
mov si,return_text
mov cx,28
mov ah,0x2F
call draw_centered_in_box
credits_wait:
mov ah,0
int 0x16
cmp al,0x1B
je credits_exit
cmp al,'m'
je credits_exit
cmp al,'M'
je credits_exit
jmp credits_wait
credits_exit:
pop si
pop di
pop dx
pop cx
pop bx
pop ax
ret
draw_centered_in_box:
push ax
push bx
push cx
push dx
push di
; si = text
; cx = text length
; ah = attribute
; di = start of box-left
; compute correct box width = box_right - box_left + 1
mov bx, box_right - box_left + 1 ; 51 chars
sub bx, cx ; free chars
shr bx, 1 ; half -> left padding
shl bx, 1 ; convert chars -> bytes
add di, bx ; shift inside box
text_draw_loop:
lodsb
stosw
loop text_draw_loop
pop di
pop dx
pop cx
pop bx
pop ax
ret
menu_input:
push ax
push bx
menu_wait:
mov ah,0
int 0x16 ; wait for key press
cmp al,'p'
je go_to_player_info
cmp al,'P'
je go_to_player_info
cmp al,'i'
je show_instr
cmp al,'I'
je show_instr
cmp al,'c'
je show_cred
cmp al,'C'
je show_cred
cmp al,'q'
je quit_game
cmp al,'Q'
je quit_game
jmp menu_wait
show_instr:
call show_instructions
call draw_menu
jmp menu_wait
show_cred:
call show_credits
call draw_menu
jmp menu_wait
go_to_player_info:
call get_player_info
jmp start_game
start_game:
mov word [current_music], music_game
mov word [note_index], 0
mov word [music_tick_count], 1
pop bx
pop ax
ret
quit_game:
call unhook_timer ; <--- IMPORTANT: STOP MUSIC BEFORE EXIT
mov ax,0x4c00
int 0x21
set_scr:
push bp
mov bp,sp
push ax
push bx
push cx
push dx
push di
push si
mov ax,0xb800
mov es,ax
mov di,0
; make the screen deserted
; fill entire screen black
color_the_screen:
mov word[es:di],0x0020 ; black space
add di,2
cmp di,4000
jne color_the_screen
; overlay grass only in cols 0-59
mov dx,0 ; row 0-24
grass_outer:
mov al,80
mul dl
add ax,0 ; start col 0
shl ax,1
mov di,ax
mov cx,60 ; 60 cols
grass_inner:
mov word[es:di],0x2020 ; solid green
add di,2
loop grass_inner
inc dl
cmp dl,25
jne grass_outer
;now draw black road
mov cx,[bp+4]
mov dx,[bp+8]
jmp make_road
;making the formula for index
set_fromula:
mov al,80
mov bl,dl ; current row
mul bl
add ax,[bp+6] ; add starting column
shl ax,1
ret
;making road structure
make_road:
call set_fromula
push cx
mov di,ax
mov cx,33 ;num of blocks
set_road_bg:
mov word[es:di],0x08DB ; grey solid
add di,2
loop set_road_bg
pop cx
inc dx
loop make_road
mov dx,[bp+8] ;reset the value of dx to point to the first row
mov cx,[bp+4]
push bx
mov bx,0 ; dash counter
set_left_lane:
;making the formula
mov al,80
mul dl
add ax,[bp + 6]
add ax,11
shl ax,1
;now making the lanes
mov di,ax
cmp bx,4
jb draw_left
mov word[es:di],0x08DB ; gap
jmp next_left
draw_left:
mov word[es:di],0x0EB3 ; yellow vertical line
next_left:
inc bx
cmp bx,6
jb no_reset_left
mov bx,0
no_reset_left:
add dl,1
loop set_left_lane
pop bx
mov dx,[bp+8]
mov cx,[bp+4]
push bx
mov bx,0 ; dash counter
set_right_lane:
;making the formula
mov al,80
mul dl
add ax,[bp + 6]
add ax,22
shl ax,1
;now making the lanes
mov di,ax
cmp bx,4
jb draw_right
mov word[es:di],0x08DB ; gap
jmp next_right
draw_right:
mov word[es:di],0x0EB3 ; yellow vertical line
next_right:
inc bx
cmp bx,6
jb no_reset_right
mov bx,0
no_reset_right:
add dl,1
loop set_right_lane
pop bx
mov dx,[bp+8]
mov cx,[bp+4]
; setting the left side border
set_left_border_lane:
;making the formula
mov al,80
mul dl
add ax,[bp + 6]
shl ax,1
;now making the lanes
mov di,ax
mov ax,0x7020 ; white bg space
test dl,1
jz even_left
mov ax,0x4020 ; red bg space
even_left:
mov word[es:di],ax
add dl,1
loop set_left_border_lane
mov dx,[bp+8]
mov cx,[bp+4]
set_right_border_lane:
;making the formula
mov al,80
mul dl
add ax,[bp + 6]
add ax,33
shl ax,1
;now making the lanes
mov di,ax
mov ax,0x7020 ; white bg space
test dl,1
jz even_right
mov ax,0x4020 ; red bg space
even_right:
mov word[es:di],ax
add dl,1
loop set_right_border_lane
pop si
pop di
pop dx
pop cx
pop bx
pop ax
pop bp
ret 6
make_tree:
push bp
mov bp,sp
push ax
push bx
push cx
push dx
push di
mov ax,0xb800
mov es,ax
mov bl,[bp+6] ; base row
mov dx,[bp+4] ; center col
mov si,bx ; save base
sub bl,4 ; top row
; top foliage: 1 block
mov al,80
mul bl
add ax,dx
shl ax,1
mov di,ax
mov word[es:di],0x2ADB ; bright green solid
; next row: 3 blocks
inc bl
mov al,80
mul bl
add ax,dx
sub ax,1
shl ax,1
mov di,ax
mov cx,3
fol_loop1:
mov word[es:di],0x2ADB
add di,2
loop fol_loop1
; next row: 5 blocks
inc bl
mov al,80
mul bl
add ax,dx
sub ax,2
shl ax,1
mov di,ax
mov cx,5
fol_loop2:
mov word[es:di],0x2ADB
add di,2
loop fol_loop2
; trunk first
inc bl
mov al,80
mul bl
add ax,dx
shl ax,1
mov di,ax
mov word[es:di],0x66DB ; brown solid
; trunk second
inc bl
mov al,80
mul bl
add ax,dx
shl ax,1
mov di,ax
mov word[es:di],0x66DB
pop di
pop dx
pop cx
pop bx
pop ax
pop bp
ret 4
make_Action_Cruiser:
push bp
mov bp,sp
push ax
push bx
push cx
push dx
push si
push di
mov ax,0xb800
mov es,ax
mov bl,[bp+6] ; rear row (base)
mov dx,[bp+4] ; center col
; Rear row (bl): body body body body body
mov al,80
mul bl
sub dx,2 ; start col -2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x0CDB ; red body
mov cx,5
rep stosw ; pos-2 to +2
; Rear wheels row (bl-1): wheel body body body wheel
dec bl
mov al,80
mul bl
mov dx,[bp+4]
sub dx,2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x0F4F ; white O wheel
stosw ; pos-2
mov ax,0x0CDB ; body
mov cx,3
rep stosw ; pos-1 to +1
mov ax,0x0F4F ; wheel
stosw ; pos+2
; Cabin row (bl-2): body window window window body
dec bl
mov al,80
mul bl
mov dx,[bp+4]
sub dx,2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x0CDB ; body (changed from side)
stosw ; pos-2
mov ax,0x0BB1 ; cyan ▒ window
mov cx,3
rep stosw ; pos-1 to +1
mov ax,0x0CDB ; body (changed from side)
stosw ; pos+2
; Front wheels row (bl-3): wheel body body body wheel (changed from hood)
dec bl
mov al,80
mul bl
mov dx,[bp+4]
sub dx,2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x0F4F ; wheel
stosw ; pos-2
mov ax,0x0CDB ; body
mov cx,3
rep stosw ; pos-1 to +1
mov ax,0x0F4F
stosw ; pos+2
; Front lights row (bl-4): light body body body light (changed, no spaces)
dec bl
mov al,80
mul bl
mov dx,[bp+4]
sub dx,2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x0E2A ; yellow * light
stosw ; pos-2
mov ax,0x0CDB ; body
mov cx,3
rep stosw ; pos-1 to +1
mov ax,0x0E2A ; light
stosw ; pos+2
pop di
pop si
pop dx
pop cx
pop bx
pop ax
pop bp
ret 4
clear_Action_Cruiser:
push bp
mov bp,sp
push ax
push bx
push cx
push dx
push si
push di
mov ax,0xb800
mov es,ax
mov bl,[bp+6] ; rear row (base)
mov dx,[bp+4] ; center col
; Rear row (bl): body body body body body
mov al,80
mul bl
sub dx,2 ; start col -2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x08DB ; grey solid
mov cx,5
rep stosw ; pos-2 to +2
; Rear wheels row (bl-1): wheel body body body wheel
dec bl
mov al,80
mul bl
mov dx,[bp+4]
sub dx,2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x08DB ; grey solid
stosw ; pos-2
mov ax,0x08DB ; grey solid
mov cx,3
rep stosw ; pos-1 to +1
mov ax,0x08DB ; grey solid
stosw ; pos+2
; Cabin row (bl-2): body window window window body
dec bl
mov al,80
mul bl
mov dx,[bp+4]
sub dx,2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x08DB ; grey solid
stosw ; pos-2
mov ax,0x08DB ; grey solid
mov cx,3
rep stosw ; pos-1 to +1
mov ax,0x08DB ; grey solid
stosw ; pos+2
; Front wheels row (bl-3): wheel body body body wheel (changed from hood)
dec bl
mov al,80
mul bl
mov dx,[bp+4]
sub dx,2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x08DB ; grey solid
stosw ; pos-2
mov ax,0x08DB ; grey solid
mov cx,3
rep stosw ; pos-1 to +1
mov ax,0x08DB ; grey solid
stosw ; pos+2
; Front lights row (bl-4): light body body body light (changed, no spaces)
dec bl
mov al,80
mul bl
mov dx,[bp+4]
sub dx,2
add ax,dx
shl ax,1
mov di,ax
mov ax,0x08DB ; grey solid
stosw ; pos-2
mov ax,0x08DB ; grey solid
mov cx,3
rep stosw ; pos-1 to +1
mov ax,0x08DB ; grey solid
stosw ; pos+2
pop di
pop si
pop dx
pop cx
pop bx
pop ax
pop bp
ret 4
draw_obstacle_row:
push bp
mov bp,sp
push ax
push bx
push cx
push dx
push si
push di
mov ax,0xb800
mov es,ax
mov dx,[bp+4] ; center col
mov bl,[bp+6] ; phase (0-4)
cmp bl,0
jne not_phase0
; Phase 0: rear body
mov ax,dx
sub ax,2
shl ax,1
mov di,ax
mov ax,0x09DB
mov cx,5
rep stosw
jmp obs_row_done
not_phase0:
cmp bl,1
jne not_phase1
; Phase 1: rear wheels
mov ax,dx
sub ax,2