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

  ViewVC Help
Powered by ViewVC 1.1.26