/[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 601 - (show annotations)
Fri Sep 2 17:19:46 2011 UTC (8 years, 8 months ago) by Chema
File size: 18658 byte(s)
Now you can enter your own names.
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_BGGREEN
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 sta SRB,x
455 dex
456 lda #$ff
457 ldy #2
458 loopsrb2
459 sta SRB,x
460 dex
461 dey
462 bpl loopsrb2
463 lda #$3f
464 sta SRB,x
465 dex
466 bpl loopsrb
467
468 ; First screen render
469 /*
470 lda #A_BGBLACK
471 sta smc_paper_1+1
472 sta smc_paper_2+1
473 */
474 jsr clr_hires
475 jsr set_ink2
476 jsr render_screen
477
478 /*
479 lda #A_BGCYAN
480 sta smc_paper_1+1
481 lda #A_BGYELLOW
482 sta smc_paper_2+1
483 jsr set_ink2
484 */
485
486 ; Clear scorepanel
487 jsr clear_scorepanel
488
489 ; Scroll the screen
490 lda #5
491 sta tmp4
492 loops
493 jsr _scroll_left
494 dec tmp4
495 bne loops
496
497 ; Initialize the lesson
498 lda #$ff
499 sta current_lesson_index
500
501 lda #<(LESCLK_VAL)
502 sta lesson_clock
503 lda #>(LESCLK_VAL)
504 sta lesson_clock+1
505
506 jmp change_lesson
507 .)
508
509
510
511 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
512 ;; Set and unset demo mode
513 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
514
515 set_demo_mode
516 .(
517 lda #0
518 sta game_mode
519
520 lda #$ff
521 sta demo_ff_00+1
522 sta demo_ff_002+1
523
524 lda #$10 ; $d0 for normal mode
525 sta demo_bpl_bne
526
527 rts
528 .)
529
530
531 unset_demo_mode
532 .(
533 lda #1
534 sta game_mode
535
536 lda #$00
537 sta demo_ff_00+1
538 sta demo_ff_002+1
539
540 lda #$d0 ; $10 for demo mode
541 sta demo_bpl_bne
542
543 rts
544 .)
545
546
547 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
548 ; Test for the main loop
549 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
550
551
552 _test_loop
553 .(
554 ; Time the frame...
555 lda #0
556 sta counter
557
558
559 ; Scroll if necessary...
560 lda pos_col
561 sec
562 sbc first_col
563 cmp #10;-4
564 bne noscrollr
565 jsr _scroll_right
566 jmp noscroll
567 noscrollr
568 cmp #28;+4
569 bne noscroll
570 jsr _scroll_left
571 noscroll
572
573 ; Deal with the lesson timer
574 ; Decrement it by one
575 lda lesson_clock
576 sec
577 sbc #1
578 sta lesson_clock
579 bcs nocarry
580 dec lesson_clock+1
581 nocarry
582 ; Is it time to change the lesson?
583 ora lesson_clock+1
584 bne notzero
585 ; It is, doit
586 jsr change_lesson
587 notzero
588
589 ; Now move the characters
590 jsr move_chars
591
592 ; If in demo mode we are finished
593 lda game_mode
594 bne play_mode
595
596 jsr ReadKey
597 beq avoidEric
598
599 ; A key was pressed, exit demo mode.
600 jsr unset_demo_mode
601 jsr change_names
602 jsr _init
603 jmp _test_loop
604
605 play_mode
606
607 ; Now move Eric, if it needs be
608 jsr deal_with_Eric
609 bcs avoidEric
610
611 ; See if it is time to move Eric
612 dec Eric_timer
613 bne avoidEric
614
615 ; Reload Eric's main action timer
616 lda #NORMAL_ERIC_TIMER
617 sta Eric_timer
618
619
620 ; Is Eric writting on a blackboard?
621 lda anim_state
622 cmp #9
623 bne nowritting
624 ; Move his hand
625 lda #10
626 jsr setEric_state
627 jmp nomidstride
628
629 nowritting
630 ; Do we have to move Eric to the midstride position?
631 ; Is Eric not midstride?
632 lda anim_state
633 cmp #4
634 bcs nomidstride
635 lsr
636 bcc nomidstride
637 ldx #0
638 jsr step_character
639
640 midtimer
641 ; Here the original version does something strange..
642 lda Eric_mid_timer
643 sta Eric_timer
644 lda #0
645 sta Eric_mid_timer
646
647 ; Don't check the keyboard this time
648 jmp avoidEric
649 nomidstride
650
651 ; Time to check the keyboard input
652 ; If Eric is writting, simply write
653 ; the character pressed.
654 lda Eric_flags
655 and #ERIC_WRITTING
656 beq notwritting
657 ; He is...
658 jsr Eric_writting
659 jmp avoidEric
660 notwritting
661 jsr process_user_input
662 avoidEric
663
664 ; Protect the speech bubble, if any
665 lda bubble_on
666 beq nobubble
667
668 ldy srb_offset
669 lda SRB,y
670 and srb_bitmask
671 sta SRB,y
672
673 lda SRB+5,y
674 and srb_bitmask
675 sta SRB+5,y
676
677 lda SRB+1,y
678 and srb_bitmask2
679 sta SRB+1,y
680
681 lda SRB+6,y
682 and srb_bitmask2
683 sta SRB+6,y
684
685 ldy srb_offset_lip
686 lda SRB,y
687 and srb_bitmask_lip
688 sta SRB,y
689
690 nobubble
691 ; Render the screen
692 jsr render_screen
693
694 ; Any defered punishment?
695 +need_to_punish_Eric
696 lda #0
697 beq nopunish
698 dec need_to_punish_Eric+1
699
700 ; Re-initialize the delay counter
701 ldy #150/2
702 sty lines_delay
703 ; Get the reason code back
704 +smc_sav_msg
705 lda #0
706 jsr punish_Eric
707 nopunish
708
709 ; Time before next move...
710 loop
711 lda counter
712 beq loop
713 jmp _test_loop
714 .)
715
716 #define NUM_KEYS 9
717 ; Keymap table
718 user_keys
719 .byt 1, 2, 3, 4
720 .byt "S", "H", "F", "W", "J"
721 key_routh
722 .byt >(up_Eric), >(left_Eric), >(down_Eric), >(right_Eric)
723 .byt >(sit_Eric), >(hit_Eric), >(fire_Eric), >(write_Eric)
724 .byt >(jump_Eric)
725 key_routl
726 .byt <(up_Eric), <(left_Eric), <(down_Eric), <(right_Eric)
727 .byt <(sit_Eric), <(hit_Eric), <(fire_Eric), <(write_Eric)
728 .byt <(jump_Eric)
729
730 process_user_input
731 .(
732 jsr ReadKeyNoBounce
733 beq end
734
735 ; Ok a key was pressed, let's check
736 ldx #NUM_KEYS-1
737 loop
738 cmp user_keys,x
739 beq found
740 dex
741 bpl loop
742 end
743 rts
744
745 found
746
747 lda key_routl,x
748 sta _smc_routine+1
749 lda key_routh,x
750 sta _smc_routine+2
751
752 ; Some keys shall be read with repetitions
753 cpx #4
754 bcs call
755 ldx #0
756 stx oldKey
757
758 call
759 ldx #0
760 _smc_routine
761 ; Call the routine
762 jmp $1234 ; SMC
763
764 .)
765
766 tab_patchcomm
767 .byt SC_TELLANGELFACE, SC_TELLEINSTEIN, SC_TELLBOYWANDER
768
769 ;; Change the current lesson
770 change_lesson
771 .(
772 ; Reset the lesson clock
773 lda #>LESCLK_VAL
774 sta lesson_clock+1
775 lda #<LESCLK_VAL
776 sta lesson_clock
777
778 ; Increment current lesson
779 inc current_lesson_index
780
781 ; Get lesson code from table
782 ldx current_lesson_index
783 lda main_timetable,x
784
785 ; Is it playtime?
786 cmp #243
787 bcc cont
788 ; Are we in demo mode?
789 ldx game_mode
790 beq cont
791 ; Select a 'special' playtime occasionally
792 tax
793
794 jsr randgen
795 and #7
796 clc
797 adc #238
798 cmp #243
799 bcs cont2
800 txa ; Get the old identifier
801 bne cont ; jump always
802 cont2
803 cmp #246
804 bcs cont
805 ; This is a special playtime, patch the
806 ; command list so the delivered message is correct
807 tay
808 lda tab_patchcomm-243,y
809 sta command_list210+1
810 tya
811 cont
812 sta current_lesson
813
814 ; Get the lesson descriptor
815 sec
816 sbc #224
817 tax
818 lda lesson_descriptors,x
819 sta lesson_descriptor
820
821 cmp #254 ; Second playtime in a row
822 bcs nobell
823 ; Ring the bell
824 jsr _ping
825 nobell
826
827 ; Clear all game flags & other matters
828 jsr reset_flags
829
830 ; Now update all characters
831 ldx #MAX_CHARACTERS-3
832 loop
833 ; Trigger the command list reset
834 lda flags,x
835 ora #RESET_COMMAND_LIST
836 sta flags,x
837
838 ; Put the name of teacher and place it in the lesson box
839
840 ; Pick up the command list number for this lesson
841 ; from the character's personal timetable. As they lie in the
842 ; Last 32 bytes of each page, starting in skool_r00 and the indexes
843 ; are 224-255, no need for more than the following:
844
845 ldy current_lesson
846 txa
847 clc
848 adc #>skool_r00
849 sta smc_ptimetable+2
850 smc_ptimetable
851 lda $1200,y ; Get the personal timetable code for this lesson
852
853 ; Now get the pointer to the command list
854 tay
855 lda command_list_table-128,y
856 sta command_list_low,x
857 lda command_list_table-127,y
858 sta command_list_high,x
859
860 dex
861 +demo_bpl_bne
862 bne loop ; Avoid dealing with Eric
863
864
865 ; Print the teacher's name and the room
866
867 jsr uncolor_box
868
869 lda game_mode
870 bne notdemo
871
872 ; We are in demo mode... print that.
873 lda #<demo_msg2
874 sta tmp0
875 lda #>demo_msg2
876 sta tmp0+1
877
878 jsr write_text_down
879
880 lda #<demo_msg
881 sta tmp0
882 lda #>demo_msg
883 sta tmp0+1
884
885 jmp printit2
886
887 notdemo
888 ; Get the room's name
889 lda #<class_names
890 sta tmp0
891 lda #>class_names
892 sta tmp0+1
893 lda lesson_descriptor
894 and #%1111
895 sec
896 sbc #1
897 jsr search_string
898
899 jsr write_text_down
900
901 ; Now the teacher's name
902 lda lesson_descriptor
903 lsr
904 lsr
905 lsr
906 lsr
907 cmp #%0100
908 bne notnone
909 ; Is it the library?
910 lda lesson_descriptor
911 and #%1111
912 cmp #DES_LIBRARY
913 bne isplaytime
914 ; Point to REVISION
915 lda #EN_REVISION
916 bne printit ; This always jumps
917
918 isplaytime
919 lda #<empty_st
920 sta tmp0
921 lda #>empty_st
922 sta tmp0+1
923 bne printit2 ; This always jumps
924
925 notnone
926 and #%11
927 clc
928 adc #5
929 printit
930 ldx #<names_extras
931 stx tmp0
932 ldx #>names_extras
933 stx tmp0+1
934 jsr search_string
935
936 printit2
937 jsr write_text_up
938
939 ; Now dump the buffer into the screen
940
941 lda #<22*8*40+15+$a000
942 sta tmp1
943 lda #>22*8*40+15+$a000
944 sta tmp1+1
945
946 jmp dump_text_buffer
947 .)
948
949 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
950 ; Routines to change the character names
951 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
952 change_names
953 .(
954 jsr clr_hires
955
956 lda #A_BGCYAN
957 sta smc_paper_2+1
958 jsr set_ink2
959 lda #A_BGYELLOW
960 sta smc_paper_2+1
961
962 lda #<$a000+40*4+3
963 sta tmp0
964 lda #>$a000+40*4+3
965 sta tmp0+1
966 lda #<st_putnames
967 ldy #>st_putnames
968 jsr print_string
969 looprk
970 jsr ReadKey
971 cmp #"Y"
972 beq start_catwalk
973 cmp #"N"
974 beq end
975 bne looprk
976 end
977 rts
978 .)
979
980 start_catwalk
981 .(
982 jsr clr_hires
983 jsr set_ink2
984
985 ; Print "CAST OF CHARACTERS"
986 lda #<$a000+40*4+13
987 sta tmp0
988 lda #>$a000+40*4+13
989 sta tmp0+1
990 lda #<st_castof
991 ldy #>st_castof
992 jsr print_string
993
994
995 ; Patch the instruction at draw_skool_tile, so no
996 ; background is drawn
997 ; It was lda #>skool_r00,clc
998 ; and we want jmp blank_tile
999 lda #$4C ;jmp
1000 sta draw_skool_tile
1001 lda #<blank_tile
1002 sta draw_skool_tile+1
1003 lda #>blank_tile
1004 sta draw_skool_tile+2
1005
1006 ; Draw the catwalk
1007 lda #%11000000
1008 ldy #35
1009 .(
1010 loop
1011 sta $a000+(40*76)+2,y
1012 dey
1013 bne loop
1014 .)
1015 ; Put all the characters offscreen
1016 ldx #MAX_CHARACTERS-1
1017 lda #150
1018 .(
1019 loop
1020 sta pos_col,x
1021 dex
1022 bpl loop
1023 .)
1024 ; Set the lefmost column of the skool to 5
1025 lda #5
1026 sta first_col
1027
1028 ; Iterate through the main characters
1029 lda #0
1030 sta tmp7
1031 loopchars
1032 ; Prepare the character position
1033 ldx tmp7
1034 lda #5
1035 sta pos_row,x
1036 lda #0
1037 sta pos_col,x
1038
1039 ; and animatory state
1040 jsr update_animstate
1041
1042 ; Is he looking right?
1043 lda flags,x
1044 ora #IS_FACING_RIGHT
1045 bne isok
1046 jsr change_direction
1047 isok
1048 ; Start the catwalk
1049 jsr walk_char_in
1050 jsr print_title
1051 jsr print_name
1052
1053 ; Ask the user to change the name
1054 jsr change_name
1055 jsr clear_name
1056
1057 ; Walk the character out
1058 ldx tmp7
1059 jsr walk_char_out
1060
1061 ; Proceed to the next character
1062 ; Beware to jump over the little kids
1063 ldx tmp7
1064 inx
1065 cpx #4
1066 bne notyet
1067 ldx #15
1068 notyet
1069 stx tmp7
1070 cpx #CHAR_WITHIT+1
1071 bne loopchars
1072
1073 ; Put back the original code at draw_skool_tile
1074 ; to lda #>skool_r00,clc
1075 lda #$A9 ;lda immediate
1076 sta draw_skool_tile
1077 lda #>skool_r00
1078 sta draw_skool_tile+1
1079 lda #$18 ; clc
1080 sta draw_skool_tile+2
1081
1082 ; We are done
1083 rts
1084 .)
1085
1086 walk_char_out
1087 walk_char_in
1088 .(
1089 lda #(3+20)*2
1090 sta tmp7+1
1091 stx loop+1
1092 loop
1093 ldx #0 ; SMC
1094 jsr step_character
1095 jsr render_screen
1096
1097 ; Wait a bit, else they run too fast
1098 ldy #50
1099 wlo
1100 ldx #$ff
1101 wl dex
1102 bne wl
1103 dey
1104 bne wlo
1105
1106 dec tmp7+1
1107 bne loop
1108 rts
1109 .)
1110
1111 table_teacher_order
1112 .byt 3,0,1,2
1113
1114 print_title
1115 .(
1116 ldx tmp7
1117 cpx #CHAR_FIRST_TEACHER
1118 bcc noteacher
1119 lda table_teacher_order-CHAR_FIRST_TEACHER,x
1120 ldy #<st_casttitles2
1121 sty tmp0
1122 ldy #>st_casttitles2
1123 sty tmp0+1
1124 jsr search_string
1125 jmp bottomline
1126 noteacher
1127 lda #<st_space
1128 sta tmp0
1129 lda #>st_space
1130 sta tmp0+1
1131 bottomline
1132 jsr write_text_up
1133 ldy #<st_casttitles
1134 sty tmp0
1135 ldy #>st_casttitles
1136 sty tmp0+1
1137 lda tmp7
1138 cmp #CHAR_FIRST_TEACHER
1139 bcc noteacher2
1140 tax
1141 lda table_teacher_order-CHAR_FIRST_TEACHER,x
1142 clc
1143 adc #4
1144 noteacher2
1145 jsr search_string
1146 jsr write_text_down
1147
1148 +dump_title
1149 lda #<$a000+40*20+14
1150 sta tmp1
1151 lda #>$a000+40*20+14
1152 sta tmp1+1
1153 jmp dump_text_buffer
1154 .)
1155
1156
1157 print_name
1158 .(
1159 ldx tmp7
1160 cpx #CHAR_FIRST_TEACHER
1161 bcc noteacher
1162 lda table_teacher_order-CHAR_FIRST_TEACHER,x
1163 ldy #<st_teacher_names
1164 ldx #>st_teacher_names
1165 jmp bottomline
1166 noteacher
1167 txa
1168 ldy #<st_char_names
1169 ldx #>st_char_names
1170 bottomline
1171 sty tmp0
1172 stx tmp0+1
1173 jsr search_string
1174 ; Save pointer with SMC in case we want to edit it
1175 lda tmp0
1176 sta pchar_name+1
1177 lda tmp0+1
1178 sta pchar_name+3
1179
1180 jsr write_text_up
1181
1182 lda #<st_space
1183 sta tmp0
1184 lda #>st_space
1185 sta tmp0+1
1186 jsr write_text_down
1187
1188 +dump_title2
1189 lda #<$a000+40*78+14
1190 sta tmp1
1191 lda #>$a000+40*78+14
1192 sta tmp1+1
1193 jmp dump_text_buffer
1194 .)
1195
1196
1197 clear_name
1198 .(
1199 lda #<st_space
1200 sta tmp0
1201 lda #>st_space
1202 sta tmp0+1
1203 jsr write_text_up
1204 jsr write_text_down
1205 jsr dump_title
1206 jmp dump_title2
1207 .)
1208
1209
1210 #define ADDR_LINE $a000+40*110
1211
1212 change_name
1213 .(
1214 ; Print Print 'C' to change name
1215 lda #<ADDR_LINE+11
1216 sta tmp0
1217 lda #>ADDR_LINE+11
1218 sta tmp0+1
1219 lda #<st_pressc
1220 ldy #>st_pressc
1221 jsr print_string
1222
1223 jsr read_key_block
1224 cmp #"C"
1225 bne end
1226
1227 jsr clear_msg_line
1228 ; Print ENTER NEW NAME
1229 lda #<ADDR_LINE+14
1230 sta tmp0
1231 lda #>ADDR_LINE+14
1232 sta tmp0+1
1233 lda #<st_entername
1234 ldy #>st_entername
1235 jsr print_string
1236
1237 jsr read_new_name
1238 end
1239 jmp clear_msg_line
1240 .)
1241
1242 read_key_block
1243 .(
1244 loop
1245 jsr ReadKeyNoBounce
1246 beq loop
1247 rts
1248 .)
1249
1250 read_new_name
1251 .(
1252 jsr clear_name
1253
1254 +pchar_name
1255 ldy #$34
1256 ldx #$12
1257 sty tmp0
1258 stx tmp0+1
1259
1260 ; Empty name
1261 lda #0
1262 ldy #13
1263 loop
1264 sta (tmp0),y
1265 dey
1266 bpl loop
1267 iny
1268 sty tmp6
1269 loop_read
1270 jsr read_key_block
1271 ldy tmp6
1272 cmp #13
1273 beq end
1274 cmp #$08 ; delete?
1275 bne nodel
1276 cpy #0
1277 beq loop_read
1278 dey
1279 sty tmp6
1280 lda #0
1281 sta (tmp0),y
1282 beq skip
1283 nodel
1284 sta (tmp0),y
1285 cpy #14
1286 beq skip
1287 inc tmp6
1288 skip
1289 lda tmp0
1290 pha
1291 lda tmp0+1
1292 pha
1293 jsr write_text_up
1294 jsr dump_title2
1295 pla
1296 sta tmp0+1
1297 pla
1298 sta tmp0
1299 jmp loop_read
1300 end
1301 rts
1302
1303 .)
1304
1305 clear_msg_line
1306 .(
1307 lda #$40
1308 ldy #35
1309 loop
1310 sta ADDR_LINE+2,y
1311 sta ADDR_LINE+2+40,y
1312 sta ADDR_LINE+2+40*2,y
1313 sta ADDR_LINE+2+40*3,y
1314 sta ADDR_LINE+2+40*4,y
1315 sta ADDR_LINE+2+40*5,y
1316 sta ADDR_LINE+2+40*6,y
1317 sta ADDR_LINE+2+40*7,y
1318 dey
1319 bpl loop
1320 rts
1321 .)

  ViewVC Help
Powered by ViewVC 1.1.26