/[projet1]/users/chema/skooldaze/init.s
Defence Force logotype

Contents of /users/chema/skooldaze/init.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 604 - (show annotations)
Tue Sep 6 21:23:50 2011 UTC (8 years, 6 months ago) by Chema
File size: 18758 byte(s)
removed bug where initially the paper was CYAN/GREEN instead of CYAN/YELLOW
1
2
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;; -----------------------------------
5 ;; Skool Daze
6 ;; The Oric Version
7 ;; -----------------------------------
8 ;; (c) Chema 2011
9 ;; enguita@gmail.com
10 ;; -----------------------------------
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
13 ;; Init code
14 ;; ---------------------
15
16
17 #include "params.h"
18 #include "text.h"
19 #include "script.h"
20
21 ; Ticks to change the lesson (originally $1500=5376)
22 ; Why is this particular define not included from params.h?
23 #define LESCLK_VAL 5376
24
25
26
27 #define _hires $ec33
28 #define _text $ec21
29 #define _ping $fa9f
30
31 .zero
32
33 tmp0 .dsb 2
34 tmp1 .dsb 2
35 tmp2 .dsb 2
36 tmp3 .dsb 2
37 tmp4 .dsb 2
38 tmp5 .dsb 2
39 tmp6 .dsb 2
40 tmp7 .dsb 2
41 op1 .dsb 2
42 op2 .dsb 2
43 tmp .dsb 2
44 ;reg0 .dsb 2
45 ;reg1 .dsb 2
46 ;reg2 .dsb 2
47 ;reg3 .dsb 2
48 ;reg4 .dsb 2
49 ;reg5 .dsb 2
50 ;reg6 .dsb 2
51 ;reg7 .dsb 2
52
53
54
55
56 .text
57
58 ; Main procedure.
59
60 _main
61 .(
62 //jsr _hires
63 //paper(6);ink(0);
64 /*
65 lda #30
66 ;lda $f934
67 sta $bfdf
68
69 lda #6
70 ldy #0
71 sty $2e0
72 sta $2e1
73 sty $2e2
74 jsr $f204 ;paper
75
76 ldy #0
77 sty $2e0
78 sty $2e1
79 sty $2e2
80 jsr $f210 ;ink
81 */
82
83 jsr set_hires
84 jsr _GenerateTables
85 jsr _init_irq_routine
86 jsr wait
87 jsr wait
88 jsr clr_hires
89
90 /* lda #A_BGCYAN
91 sta smc_ink_1+1
92 lda #A_BGGREEN
93 sta smc_ink_2+1
94 jsr set_ink2
95 */
96
97 +restart_game
98 ; Set demo mode
99 jsr set_demo_mode
100
101 jsr _init
102
103 /*
104 lda #100
105 sta tmp+1
106 loop
107 jsr set_border
108 dec tmp+1
109 bne loop
110 */
111 jmp _test_loop
112 .)
113
114
115 set_hires
116 .(
117 ;lda #30
118 lda $f934
119 sta $bfdf
120
121 lda #A_BGBLACK
122 sta $bf68
123 sta $bf68+40
124 sta $bf68+40*2
125 rts
126 .)
127
128 clr_hires
129 .(
130 ldy #<($a000)
131 sty tmp
132 ldy #>($a000)
133 sty tmp+1
134 ldx #176
135 loop2
136 ldy #39
137 lda #$40
138 loop
139 sta (tmp),y
140 dey
141 ;cpy #1
142 ;bne loop
143 bpl loop
144 /*
145 lda #A_FWBLACK
146 sta (tmp),y
147 dey
148 lda #A_BGCYAN
149 sta (tmp),y
150 */
151 lda tmp
152 clc
153 adc #40
154 sta tmp
155 bcc nocarry
156 inc tmp+1
157 nocarry
158 dex
159 bne loop2
160 end
161 rts
162 .)
163
164
165 set_ink2
166 .(
167 ldy #<($a000)
168 sty tmp
169 ldy #>($a000)
170 sty tmp+1
171
172 ldx #(176/2)
173 loop
174 ldy #0
175 +smc_paper_1
176 lda #A_BGCYAN
177 sta (tmp),y
178 iny
179 +smc_ink_1
180 lda #A_FWBLACK
181 sta (tmp),y
182
183 ldy #40
184 +smc_paper_2
185 lda #A_BGYELLOW
186 sta (tmp),y
187 iny
188 +smc_ink_2
189 lda #A_FWBLACK
190 sta (tmp),y
191
192 lda tmp
193 clc
194 adc #80
195 sta tmp
196 bcc nocarry
197 inc tmp+1
198 nocarry
199
200 dex
201 bne loop
202 end
203 rts
204 .)
205
206
207 flash_border
208 .(
209 stx savx+1
210 sty savy+1
211 jsr set_border
212 jsr set_border
213 savx
214 ldx #0
215 savy
216 ldy #0
217 rts
218 .)
219 set_border
220 .(
221 ; First 4 lines
222 .(
223 ldx #40*4
224 loop
225 lda $a000-1,x
226 eor #$80
227 sta $a000-1,x
228 dex
229 bne loop
230 .)
231 ; Middle 160 lines
232
233 .(
234 lda #<($a000+(4*40))
235 sta tmp0
236 lda #>($a000+(4*40))
237 sta tmp0+1
238
239
240 ldx #168
241 loopa
242 ldy #0
243 lda (tmp0),y
244 eor #$80
245 sta (tmp0),y
246 iny
247 lda (tmp0),y
248 eor #$80
249 sta (tmp0),y
250 ldy #38
251 lda (tmp0),y
252 eor #$80
253 sta (tmp0),y
254 iny
255 lda (tmp0),y
256 eor #$80
257 sta (tmp0),y
258
259
260 lda tmp0
261 clc
262 adc #40
263 sta tmp0
264 bcc nocarry
265 inc tmp0+1
266 nocarry
267
268 dex
269 bne loopa
270 .)
271
272
273 ; Last 4 lines
274 .(
275 ldx #40*4
276 loop
277 lda $a000+(4+168)*40-1,x
278 eor #$80
279 sta $a000+(4+168)*40-1,x
280 dex
281 bne loop
282 .)
283 rts
284 .)
285
286 ;; Resets the game flags
287 reset_flags
288 .(
289 ; Reset all the game flags
290 ; after lesson change
291 ldy #5
292 lda #0
293 loopf
294 sta lesson_status,y
295 dey
296 bpl loopf
297 rts
298
299 .)
300
301 _init
302 .(
303 ; Reset game flags
304 ;jsr reset_flags
305
306 ; Initialize other game flags
307 lda #$fe
308 sta first_col
309
310 lda #0
311 sta vis_col
312 sta vis_row
313 sta tile_col
314 ;sta first_col
315 sta current_lesson_index
316 sta Eric_flags
317 sta Eric_knockout
318 sta lines_delay
319 sta score
320 sta score+1
321 sta lines
322 sta lines+1
323
324 .(
325 ldx #20
326 loop
327 ; Set initial positions
328 lda ini_pos_col,x
329 sta pos_col,x
330 lda #17
331 sta pos_row,x
332
333 ; And animatory state, direction and flags
334
335 lda #0
336 jsr update_animstate
337
338 lda ini_flags,x
339 eor flags,x
340 and #IS_FACING_RIGHT
341 beq noright
342 jsr change_direction
343 noright
344
345 lda ini_flags,x
346 sta flags,x
347
348 ; Now the commands
349 lda #0
350 sta uni_subcom_high,x
351 sta cont_subcom_high,x
352 sta i_subcom_high,x
353 sta command_list_high,x
354 sta cur_command_high,x
355
356 dex
357 bpl loop
358 .)
359 ; Initialize game variables
360 lda #0
361 sta last_char_moved
362
363 ; Generate new safe combination and Creak's birth year
364 .(
365 ldx #3
366 loop
367 jsr randgen
368 and #15 ; 0<=A<=15
369 clc
370 adc #65
371 sta tab_safecodes,x
372 dex
373 bpl loop
374 .)
375
376 ; Now for the year...
377 generatey
378 jsr randgen
379 cmp #21
380 bcs generatey
381
382 ;Store the identifier
383 sta birthyear_id
384
385 ; Get the digits
386 sta tmp
387 asl
388 asl
389 adc tmp
390
391 tax
392 .(
393 ldy #0
394 loop
395 lda st_years,x
396 sta creak_year,y
397 inx
398 iny
399 cpy #4
400 bne loop
401 .)
402 ; Reset Eric's main action timer
403 lda #INITIAL_ERIC_TIMER
404 sta Eric_timer
405 lda #0
406 sta Eric_mid_timer
407
408 ; Clear blackboards
409 .(
410 ldx #2
411 loopbb
412 lda tab_bboards_high,x
413 sta tmp+1
414 lda tab_bboards_low,x
415 sta tmp
416
417 ldy #0
418 lda (tmp),y
419 sta loop+1
420 iny
421 lda (tmp),y
422 sta loop+2
423 iny
424 lda #1
425 sta (tmp),y
426 iny
427 lda #0
428 sta (tmp),y
429 ldy #4
430 lda #$ff
431 sta (tmp),y
432
433 ldy #11
434 lda #0
435 sta (tmp),y
436
437 dec loop+1
438
439 ldy #11*2*8
440 lda #$7f
441 loop
442 sta board_white,y
443 dey
444 bne loop
445
446 dex
447 bpl loopbb
448 .)
449 ; Initialize SRB
450
451 ldx #(21*5-1)
452 loopsrb
453 ;lda #$fc
454 lda #0
455 sta SRB,x
456 dex
457 ;lda #$ff
458 lda #0
459 ldy #2
460 loopsrb2
461 sta SRB,x
462 dex
463 dey
464 bpl loopsrb2
465 ;lda #$3f
466 lda #0
467 sta SRB,x
468 dex
469 bpl loopsrb
470
471 ; First screen render
472 /*
473 lda #A_BGBLACK
474 sta smc_paper_1+1
475 sta smc_paper_2+1
476 */
477 jsr clr_hires
478 jsr set_ink2
479 ;jsr render_screen
480
481 /*
482 lda #A_BGCYAN
483 sta smc_paper_1+1
484 lda #A_BGYELLOW
485 sta smc_paper_2+1
486 jsr set_ink2
487 */
488
489 ; Clear scorepanel
490 jsr clear_scorepanel
491
492 lda #$da
493 sta first_col
494
495 ; Scroll the screen
496 lda #42
497 sta tmp4
498 loops
499 jsr scroll1_left
500 dec tmp4
501 bne loops
502
503 ; Initialize the lesson
504 lda #$ff
505 sta current_lesson_index
506
507 lda #<(LESCLK_VAL)
508 sta lesson_clock
509 lda #>(LESCLK_VAL)
510 sta lesson_clock+1
511
512 jmp change_lesson
513 .)
514
515
516
517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
518 ;; Set and unset demo mode
519 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
520
521 set_demo_mode
522 .(
523 lda #0
524 sta game_mode
525
526 lda #$ff
527 sta demo_ff_00+1
528 sta demo_ff_002+1
529
530 lda #$10 ; $d0 for normal mode
531 sta demo_bpl_bne
532
533 rts
534 .)
535
536
537 unset_demo_mode
538 .(
539 lda #1
540 sta game_mode
541
542 lda #$00
543 sta demo_ff_00+1
544 sta demo_ff_002+1
545
546 lda #$d0 ; $10 for demo mode
547 sta demo_bpl_bne
548
549 rts
550 .)
551
552
553 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
554 ; Test for the main loop
555 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
556
557
558 _test_loop
559 .(
560 ; Time the frame...
561 lda #0
562 sta counter
563
564
565 ; Scroll if necessary...
566 lda pos_col
567 sec
568 sbc first_col
569 cmp #10;-4
570 bne noscrollr
571 jsr _scroll_right
572 jmp noscroll
573 noscrollr
574 cmp #28;+4
575 bne noscroll
576 jsr _scroll_left
577 noscroll
578
579 ; Deal with the lesson timer
580 ; Decrement it by one
581 lda lesson_clock
582 sec
583 sbc #1
584 sta lesson_clock
585 bcs nocarry
586 dec lesson_clock+1
587 nocarry
588 ; Is it time to change the lesson?
589 ora lesson_clock+1
590 bne notzero
591 ; It is, doit
592 jsr change_lesson
593 notzero
594
595 ; Now move the characters
596 jsr move_chars
597
598 ; If in demo mode we are finished
599 lda game_mode
600 bne play_mode
601
602 jsr ReadKey
603 beq avoidEric
604
605 ; A key was pressed, exit demo mode.
606 jsr unset_demo_mode
607 jsr change_names
608 jsr _init
609 jmp _test_loop
610
611 play_mode
612
613 ; Now move Eric, if it needs be
614 jsr deal_with_Eric
615 bcs avoidEric
616
617 ; See if it is time to move Eric
618 dec Eric_timer
619 bne avoidEric
620
621 ; Reload Eric's main action timer
622 lda #NORMAL_ERIC_TIMER
623 sta Eric_timer
624
625
626 ; Is Eric writting on a blackboard?
627 lda anim_state
628 cmp #9
629 bne nowritting
630 ; Move his hand
631 lda #10
632 jsr setEric_state
633 jmp nomidstride
634
635 nowritting
636 ; Do we have to move Eric to the midstride position?
637 ; Is Eric not midstride?
638 lda anim_state
639 cmp #4
640 bcs nomidstride
641 lsr
642 bcc nomidstride
643 ldx #0
644 jsr step_character
645
646 midtimer
647 ; Here the original version does something strange..
648 lda Eric_mid_timer
649 sta Eric_timer
650 lda #0
651 sta Eric_mid_timer
652
653 ; Don't check the keyboard this time
654 jmp avoidEric
655 nomidstride
656
657 ; Time to check the keyboard input
658 ; If Eric is writting, simply write
659 ; the character pressed.
660 lda Eric_flags
661 and #ERIC_WRITTING
662 beq notwritting
663 ; He is...
664 jsr Eric_writting
665 jmp avoidEric
666 notwritting
667 jsr process_user_input
668 avoidEric
669
670 ; Protect the speech bubble, if any
671 lda bubble_on
672 beq nobubble
673
674 ldy srb_offset
675 lda SRB,y
676 and srb_bitmask
677 sta SRB,y
678
679 lda SRB+5,y
680 and srb_bitmask
681 sta SRB+5,y
682
683 lda SRB+1,y
684 and srb_bitmask2
685 sta SRB+1,y
686
687 lda SRB+6,y
688 and srb_bitmask2
689 sta SRB+6,y
690
691 ldy srb_offset_lip
692 lda SRB,y
693 and srb_bitmask_lip
694 sta SRB,y
695
696 nobubble
697 ; Render the screen
698 jsr render_screen
699
700 ; Any defered punishment?
701 +need_to_punish_Eric
702 lda #0
703 beq nopunish
704 dec need_to_punish_Eric+1
705
706 ; Re-initialize the delay counter
707 ldy #150/2
708 sty lines_delay
709 ; Get the reason code back
710 +smc_sav_msg
711 lda #0
712 jsr punish_Eric
713 nopunish
714
715 ; Time before next move...
716 loop
717 lda counter
718 beq loop
719 jmp _test_loop
720 .)
721
722 #define NUM_KEYS 9
723 ; Keymap table
724 user_keys
725 .byt 1, 2, 3, 4
726 .byt "S", "H", "F", "W", "J"
727 key_routh
728 .byt >(up_Eric), >(left_Eric), >(down_Eric), >(right_Eric)
729 .byt >(sit_Eric), >(hit_Eric), >(fire_Eric), >(write_Eric)
730 .byt >(jump_Eric)
731 key_routl
732 .byt <(up_Eric), <(left_Eric), <(down_Eric), <(right_Eric)
733 .byt <(sit_Eric), <(hit_Eric), <(fire_Eric), <(write_Eric)
734 .byt <(jump_Eric)
735
736 process_user_input
737 .(
738 jsr ReadKeyNoBounce
739 beq end
740
741 ; Ok a key was pressed, let's check
742 ldx #NUM_KEYS-1
743 loop
744 cmp user_keys,x
745 beq found
746 dex
747 bpl loop
748 end
749 rts
750
751 found
752
753 lda key_routl,x
754 sta _smc_routine+1
755 lda key_routh,x
756 sta _smc_routine+2
757
758 ; Some keys shall be read with repetitions
759 cpx #4
760 bcs call
761 ldx #0
762 stx oldKey
763
764 call
765 ldx #0
766 _smc_routine
767 ; Call the routine
768 jmp $1234 ; SMC
769
770 .)
771
772 tab_patchcomm
773 .byt SC_TELLANGELFACE, SC_TELLEINSTEIN, SC_TELLBOYWANDER
774
775 ;; Change the current lesson
776 change_lesson
777 .(
778 ; Reset the lesson clock
779 lda #>LESCLK_VAL
780 sta lesson_clock+1
781 lda #<LESCLK_VAL
782 sta lesson_clock
783
784 ; Increment current lesson
785 inc current_lesson_index
786
787 ; Get lesson code from table
788 ldx current_lesson_index
789 lda main_timetable,x
790
791 ; Is it playtime?
792 cmp #243
793 bcc cont
794 ; Are we in demo mode?
795 ldx game_mode
796 beq cont
797 ; Select a 'special' playtime occasionally
798 tax
799
800 jsr randgen
801 and #7
802 clc
803 adc #238
804 cmp #243
805 bcs cont2
806 txa ; Get the old identifier
807 bne cont ; jump always
808 cont2
809 cmp #246
810 bcs cont
811 ; This is a special playtime, patch the
812 ; command list so the delivered message is correct
813 tay
814 lda tab_patchcomm-243,y
815 sta command_list210+1
816 tya
817 cont
818 sta current_lesson
819
820 ; Get the lesson descriptor
821 sec
822 sbc #224
823 tax
824 lda lesson_descriptors,x
825 sta lesson_descriptor
826
827 cmp #254 ; Second playtime in a row
828 bcs nobell
829 ; Ring the bell
830 jsr _ping
831 nobell
832
833 ; Clear all game flags & other matters
834 jsr reset_flags
835
836 ; Now update all characters
837 ldx #MAX_CHARACTERS-3
838 loop
839 ; Trigger the command list reset
840 lda flags,x
841 ora #RESET_COMMAND_LIST
842 sta flags,x
843
844 ; Put the name of teacher and place it in the lesson box
845
846 ; Pick up the command list number for this lesson
847 ; from the character's personal timetable. As they lie in the
848 ; Last 32 bytes of each page, starting in skool_r00 and the indexes
849 ; are 224-255, no need for more than the following:
850
851 ldy current_lesson
852 txa
853 clc
854 adc #>skool_r00
855 sta smc_ptimetable+2
856 smc_ptimetable
857 lda $1200,y ; Get the personal timetable code for this lesson
858
859 ; Now get the pointer to the command list
860 tay
861 lda command_list_table-128,y
862 sta command_list_low,x
863 lda command_list_table-127,y
864 sta command_list_high,x
865
866 dex
867 +demo_bpl_bne
868 bne loop ; Avoid dealing with Eric
869
870
871 ; Print the teacher's name and the room
872
873 jsr uncolor_box
874
875 lda game_mode
876 bne notdemo
877
878 ; We are in demo mode... print that.
879 lda #<demo_msg2
880 sta tmp0
881 lda #>demo_msg2
882 sta tmp0+1
883
884 jsr write_text_down
885
886 lda #<demo_msg
887 sta tmp0
888 lda #>demo_msg
889 sta tmp0+1
890
891 jmp printit2
892
893 notdemo
894 ; Get the room's name
895 lda #<class_names
896 sta tmp0
897 lda #>class_names
898 sta tmp0+1
899 lda lesson_descriptor
900 and #%1111
901 sec
902 sbc #1
903 jsr search_string
904
905 jsr write_text_down
906
907 ; Now the teacher's name
908 lda lesson_descriptor
909 lsr
910 lsr
911 lsr
912 lsr
913 cmp #%0100
914 bne notnone
915 ; Is it the library?
916 lda lesson_descriptor
917 and #%1111
918 cmp #DES_LIBRARY
919 bne isplaytime
920 ; Point to REVISION
921 lda #EN_REVISION
922 bne printit ; This always jumps
923
924 isplaytime
925 lda #<empty_st
926 sta tmp0
927 lda #>empty_st
928 sta tmp0+1
929 bne printit2 ; This always jumps
930
931 notnone
932 and #%11
933 clc
934 adc #5
935 printit
936 ldx #<names_extras
937 stx tmp0
938 ldx #>names_extras
939 stx tmp0+1
940 jsr search_string
941
942 printit2
943 jsr write_text_up
944
945 ; Now dump the buffer into the screen
946
947 lda #<22*8*40+15+$a000
948 sta tmp1
949 lda #>22*8*40+15+$a000
950 sta tmp1+1
951
952 jmp dump_text_buffer
953 .)
954
955 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
956 ; Routines to change the character names
957 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
958 change_names
959 .(
960 jsr clr_hires
961
962 lda #A_BGCYAN
963 sta smc_paper_2+1
964 jsr set_ink2
965
966 lda #<$a000+40*4+3
967 sta tmp0
968 lda #>$a000+40*4+3
969 sta tmp0+1
970 lda #<st_putnames
971 ldy #>st_putnames
972 jsr print_string
973 looprk
974 jsr ReadKey
975 cmp #"Y"
976 beq start_catwalk
977 cmp #"N"
978 beq end
979 bne looprk
980 end
981 lda #A_BGYELLOW
982 sta smc_paper_2+1
983 rts
984 .)
985
986 start_catwalk
987 .(
988 jsr clr_hires
989 jsr set_ink2
990 lda #A_BGYELLOW
991 sta smc_paper_2+1
992
993 ; Print "CAST OF CHARACTERS"
994 lda #<$a000+40*4+13
995 sta tmp0
996 lda #>$a000+40*4+13
997 sta tmp0+1
998 lda #<st_castof
999 ldy #>st_castof
1000 jsr print_string
1001
1002
1003 ; Patch the instruction at draw_skool_tile, so no
1004 ; background is drawn
1005 ; It was lda #>skool_r00,clc
1006 ; and we want jmp blank_tile
1007 lda #$4C ;jmp
1008 sta draw_skool_tile
1009 lda #<blank_tile
1010 sta draw_skool_tile+1
1011 lda #>blank_tile
1012 sta draw_skool_tile+2
1013
1014 ; Draw the catwalk
1015 lda #%11000000
1016 ldy #35
1017 .(
1018 loop
1019 sta $a000+(40*76)+2,y
1020 dey
1021 bne loop
1022 .)
1023 ; Put all the characters offscreen
1024 ldx #MAX_CHARACTERS-1
1025 lda #150
1026 .(
1027 loop
1028 sta pos_col,x
1029 dex
1030 bpl loop
1031 .)
1032 ; Set the lefmost column of the skool to 5
1033 lda #5
1034 sta first_col
1035
1036 ; Iterate through the main characters
1037 lda #0
1038 sta tmp7
1039 loopchars
1040 ; Prepare the character position
1041 ldx tmp7
1042 lda #5
1043 sta pos_row,x
1044 lda #0
1045 sta pos_col,x
1046
1047 ; and animatory state
1048 jsr update_animstate
1049
1050 ; Is he looking right?
1051 lda flags,x
1052 and #IS_FACING_RIGHT
1053 bne isok
1054 jsr change_direction
1055 isok
1056 ; Start the catwalk
1057 jsr walk_char_in
1058 jsr print_title
1059 jsr print_name
1060
1061 ; Ask the user to change the name
1062 jsr change_name
1063 jsr clear_name
1064
1065 ; Walk the character out
1066 ldx tmp7
1067 jsr walk_char_out
1068
1069 ; Proceed to the next character
1070 ; Beware to jump over the little kids
1071 ldx tmp7
1072 inx
1073 cpx #4
1074 bne notyet
1075 ldx #15
1076 notyet
1077 stx tmp7
1078 cpx #CHAR_WITHIT+1
1079 bne loopchars
1080
1081 ; Put back the original code at draw_skool_tile
1082 ; to lda #>skool_r00,clc
1083 lda #$A9 ;lda immediate
1084 sta draw_skool_tile
1085 lda #>skool_r00
1086 sta draw_skool_tile+1
1087 lda #$18 ; clc
1088 sta draw_skool_tile+2
1089
1090 ; We are done
1091 rts
1092 .)
1093
1094 walk_char_out
1095 walk_char_in
1096 .(
1097 lda #(3+19)*2
1098 sta tmp7+1
1099 stx loop+1
1100 loop
1101 ldx #0 ; SMC
1102 jsr step_character
1103 jsr render_screen
1104
1105 ; Wait a bit, else they run too fast
1106 ldy #30
1107 wlo
1108 ldx #$ff
1109 wl dex
1110 bne wl
1111 dey
1112 bne wlo
1113
1114 dec tmp7+1
1115 bne loop
1116 rts
1117 .)
1118
1119 table_teacher_order
1120 .byt 3,0,1,2
1121
1122 print_title
1123 .(
1124 ldx tmp7
1125 cpx #CHAR_FIRST_TEACHER
1126 bcc noteacher
1127 lda table_teacher_order-CHAR_FIRST_TEACHER,x
1128 ldy #<st_casttitles2
1129 sty tmp0
1130 ldy #>st_casttitles2
1131 sty tmp0+1
1132 jsr search_string
1133 jmp bottomline
1134 noteacher
1135 lda #<st_space
1136 sta tmp0
1137 lda #>st_space
1138 sta tmp0+1
1139 bottomline
1140 jsr write_text_up
1141 ldy #<st_casttitles
1142 sty tmp0
1143 ldy #>st_casttitles
1144 sty tmp0+1
1145 lda tmp7
1146 cmp #CHAR_FIRST_TEACHER
1147 bcc noteacher2
1148 tax
1149 lda table_teacher_order-CHAR_FIRST_TEACHER,x
1150 clc
1151 adc #4
1152 noteacher2
1153 jsr search_string
1154 jsr write_text_down
1155
1156 +dump_title
1157 lda #<$a000+40*20+14
1158 sta tmp1
1159 lda #>$a000+40*20+14
1160 sta tmp1+1
1161 jmp dump_text_buffer
1162 .)
1163
1164
1165 print_name
1166 .(
1167 ldx tmp7
1168 cpx #CHAR_FIRST_TEACHER
1169 bcc noteacher
1170 lda table_teacher_order-CHAR_FIRST_TEACHER,x
1171 ldy #<st_teacher_names
1172 ldx #>st_teacher_names
1173 jmp bottomline
1174 noteacher
1175 txa
1176 ldy #<st_char_names
1177 ldx #>st_char_names
1178 bottomline
1179 sty tmp0
1180 stx tmp0+1
1181 jsr search_string
1182 ; Save pointer with SMC in case we want to edit it
1183 lda tmp0
1184 sta pchar_name+1
1185 lda tmp0+1
1186 sta pchar_name+3
1187
1188 jsr write_text_up
1189
1190 lda #<st_space
1191 sta tmp0
1192 lda #>st_space
1193 sta tmp0+1
1194 jsr write_text_down
1195
1196 +dump_title2
1197 lda #<$a000+40*78+14
1198 sta tmp1
1199 lda #>$a000+40*78+14
1200 sta tmp1+1
1201 jmp dump_text_buffer
1202 .)
1203
1204
1205 clear_name
1206 .(
1207 lda #<st_space
1208 sta tmp0
1209 lda #>st_space
1210 sta tmp0+1
1211 jsr write_text_up
1212 jsr write_text_down
1213 jsr dump_title
1214 jmp dump_title2
1215 .)
1216
1217
1218 #define ADDR_LINE $a000+40*110
1219
1220 change_name
1221 .(
1222 ; Print Print 'C' to change name
1223 lda #<ADDR_LINE+11
1224 sta tmp0
1225 lda #>ADDR_LINE+11
1226 sta tmp0+1
1227 lda #<st_pressc
1228 ldy #>st_pressc
1229 jsr print_string
1230
1231 jsr read_key_block
1232 cmp #"C"
1233 bne end
1234
1235 jsr clear_msg_line
1236 ; Print ENTER NEW NAME
1237 lda #<ADDR_LINE+14
1238 sta tmp0
1239 lda #>ADDR_LINE+14
1240 sta tmp0+1
1241 lda #<st_entername
1242 ldy #>st_entername
1243 jsr print_string
1244
1245 jsr read_new_name
1246 end
1247 jmp clear_msg_line
1248 .)
1249
1250 read_key_block
1251 .(
1252 loop
1253 jsr ReadKeyNoBounce
1254 beq loop
1255 rts
1256 .)
1257
1258 read_new_name
1259 .(
1260 jsr clear_name
1261
1262 +pchar_name
1263 ldy #$34
1264 ldx #$12
1265 sty tmp0
1266 stx tmp0+1
1267
1268 ; Empty name
1269 lda #0
1270 ldy #13
1271 loop
1272 sta (tmp0),y
1273 dey
1274 bpl loop
1275 iny
1276 sty tmp6
1277 loop_read
1278 jsr read_key_block
1279 ldy tmp6
1280 cmp #13
1281 beq end
1282 cmp #$08 ; delete?
1283 bne nodel
1284 cpy #0
1285 beq loop_read
1286 dey
1287 sty tmp6
1288 lda #0
1289 sta (tmp0),y
1290 beq skip
1291 nodel
1292 sta (tmp0),y
1293 cpy #12
1294 beq skip
1295 inc tmp6
1296 skip
1297 lda tmp0
1298 pha
1299 lda tmp0+1
1300 pha
1301 jsr write_text_up
1302 jsr dump_title2
1303 pla
1304 sta tmp0+1
1305 pla
1306 sta tmp0
1307 jmp loop_read
1308 end
1309 rts
1310
1311 .)
1312
1313 clear_msg_line
1314 .(
1315 lda #$40
1316 ldy #35
1317 loop
1318 sta ADDR_LINE+2,y
1319 sta ADDR_LINE+2+40,y
1320 sta ADDR_LINE+2+40*2,y
1321 sta ADDR_LINE+2+40*3,y
1322 sta ADDR_LINE+2+40*4,y
1323 sta ADDR_LINE+2+40*5,y
1324 sta ADDR_LINE+2+40*6,y
1325 sta ADDR_LINE+2+40*7,y
1326 dey
1327 bpl loop
1328 rts
1329 .)

  ViewVC Help
Powered by ViewVC 1.1.26