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

  ViewVC Help
Powered by ViewVC 1.1.26