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

  ViewVC Help
Powered by ViewVC 1.1.26