• R/O
  • SSH
  • HTTPS

oricsdk: Commit


Commit MetaInfo

Revision1364 (tree)
Time2016-01-26 04:41:26
Authordbug

Log Message

Removed some unused files, added some square root code from #c64

Change Summary

  • delete: users/dbug/games/GlobalGameJam2016/code/sprite.s
  • delete: users/dbug/games/GlobalGameJam2016/code/player.s
  • delete: users/dbug/games/GlobalGameJam2016/code/misc_stuff.c
  • delete: users/dbug/games/GlobalGameJam2016/code/rasters.s
  • modified: users/dbug/games/GlobalGameJam2016/design.txt (diff)

Incremental Difference

--- users/dbug/games/GlobalGameJam2016/code/sprite.s (revision 1363)
+++ users/dbug/games/GlobalGameJam2016/code/sprite.s (nonexistent)
@@ -1,1085 +0,0 @@
1-
2-
3- .zero
4-
5-OldByte .dsb 1
6-ShiftCount .dsb 1
7-
8-_xpos .dsb 1
9-_xdir .dsb 1
10-
11-_ypos .dsb 1
12-_ydir .dsb 1
13-
14-_BigAngle .dsb 1
15-
16-
17- .text
18-
19-IncTmp0
20- clc
21- lda tmp0+0
22- adc #1
23- sta tmp0+0
24- lda tmp0+1
25- adc #0
26- sta tmp0+1
27- rts
28-
29-Add40Tmp1
30-.(
31- clc
32- lda tmp1
33- adc #40
34- sta tmp1
35- bcc skip_dst
36- inc tmp1+1
37-skip_dst
38- rts
39-.)
40-
41-
42-DefenceForceMelonStyle
43- .byt 10,"Defence" ; Force"
44- .byt "F"+128
45- .byt "o"+128
46- .byt "r"+128
47- .byt "c"+128
48- .byt "e"+128
49- .byt "."
50-DefenceForceMelonStyleEnd
51-
52-_DrawDefenceForceLogo
53-.(
54- ldx #DefenceForceMelonStyleEnd-DefenceForceMelonStyle
55-loop
56- lda DefenceForceMelonStyle-1,x
57- ;eor #128
58- sta $bb80+27*40-(DefenceForceMelonStyleEnd-DefenceForceMelonStyle)-1,x
59- sta $bb80+28*40-(DefenceForceMelonStyleEnd-DefenceForceMelonStyle)-1,x
60- dex
61- bne loop
62- rts
63-.)
64-
65-
66-_ColorTable
67- .byt 4
68- .byt 6
69- .byt 4
70- .byt 4
71- .byt 4
72- .byt 4
73- .byt 1
74- .byt 4
75- .byt 1
76- .byt 1
77- .byt 1
78- .byt 1
79- .byt 1
80- .byt 3
81- .byt 1
82- .byt 3
83- .byt 3
84- .byt 3
85- .byt 3
86- .byt 3
87- .byt 7
88- .byt 3
89- .byt 7
90- .byt 7
91- .byt 7
92- .byt 7
93- .byt 6
94- .byt 7
95- .byt 6
96- .byt 6
97- .byt 6
98- .byt 6
99-
100-
101-_FadeToBlackBetweenRasters
102-.(
103- lda #<$a000+55*40
104- sta tmp1+0
105- lda #>$a000+55*40
106- sta tmp1+1
107-
108- ldx #142
109-loop_y
110- lda #64
111-
112- ldy #39
113-loop_x
114- sta (tmp1),y
115- dey
116- bpl loop_x
117-
118- jsr Add40Tmp1
119-
120- dex
121- bne loop_y
122-
123- rts
124-.)
125-
126-
127-_EraseHalfScreen
128- lda #<$a000+55*40
129- sta tmp1+0
130- lda #>$a000+55*40
131- sta tmp1+1
132-
133- ldx #142
134- jmp DoErase
135-
136-_EraseScreen
137- lda #<$a000+1
138- sta tmp1+0
139- lda #>$a000+1
140- sta tmp1+1
141-
142- ldx #200
143-DoErase
144-.(
145-loop_y
146- ldy #1
147-loop_x
148- lda #64
149- sta (tmp1),y
150- iny
151- cpy #40
152- bne loop_x
153-
154- jsr Add40Tmp1
155-
156- dex
157- bne loop_y
158- rts
159-.)
160-
161-
162-_DisplayLogoSize .byt 1
163-
164-_ScaleCounter .byt 0
165-
166-_DisplayMusicLogoStretch
167- lda #<_LogoBuffer_MUsic
168- sta tmp0+0
169- lda #>_LogoBuffer_MUsic
170- sta tmp0+1
171-.(
172- sec
173- lda #100+50
174- sbc _DisplayLogoSize
175- tax
176-
177- ;ldx #70
178- clc
179- lda _ScreenAddrLow,x
180- adc #10
181- sta tmp1+0
182- lda _ScreenAddrHigh,x
183- adc #0
184- sta tmp1+1
185-
186- lda #0
187- sta _ScaleCounter
188-
189- .(
190- ldx #10
191-loop_clear
192- ; Black line on top
193- ldy #0
194- lda #64
195-loop_x
196- sta (tmp1),y
197- iny
198- cpy #20
199- bne loop_x
200- jsr Add40Tmp1
201- dex
202- bne loop_clear
203- .)
204-
205- .(
206- ; Rescale logo
207- ldx _DisplayLogoSize
208-loop_y
209- ldy #0
210-loop_x
211- lda (tmp0),y
212- sta (tmp1),y
213- iny
214- cpy #20
215- bne loop_x
216-
217-loop_scale_add
218- clc
219- lda tmp0
220- adc #20
221- sta tmp0
222- bcc skip_src
223- inc tmp0+1
224- clc
225-skip_src
226-
227- clc
228- lda _ScaleCounter
229- adc _DisplayLogoSize
230- sta _ScaleCounter
231-
232- cmp #100
233- bcc loop_scale_add
234-
235- sec
236- lda _ScaleCounter
237- sbc #100
238- sta _ScaleCounter
239-
240-
241- jsr Add40Tmp1
242-
243- dex
244- bne loop_y
245- .)
246-
247- .(
248- ; Black line on bottom
249- ldy #0
250- lda #64
251-loop_x
252- sta (tmp1),y
253- iny
254- cpy #20
255- bne loop_x
256- jsr Add40Tmp1
257- .)
258- rts
259-.)
260-
261-
262-_DisplayMusicLogo
263- lda #<_LogoBuffer_MUsic
264- sta tmp0+0
265- lda #>_LogoBuffer_MUsic
266- sta tmp0+1
267- jmp DisplayLogoCommon
268-
269-_DisplayHeadLogo
270- lda #<_LogoBuffer_Headed
271- sta tmp0+0
272- lda #>_LogoBuffer_Headed
273- sta tmp0+1
274- jmp DisplayLogoCommon
275-
276-_DisplayFireLogo
277- lda #<_LogoBuffer_Fire
278- sta tmp0+0
279- lda #>_LogoBuffer_Fire
280- sta tmp0+1
281- jmp DisplayLogoCommon
282-
283-DisplayLogoCommon
284-.(
285- lda #<$a000+10+40*70
286- sta tmp1+0
287- lda #>$a000+10+40*70
288- sta tmp1+1
289-
290- ldx #100
291-loop_y
292- ldy #0
293-loop_x
294- lda (tmp0),y
295- sta (tmp1),y
296- iny
297- cpy #20
298- bne loop_x
299-
300- clc
301- lda tmp0
302- adc #20
303- sta tmp0
304- bcc skip_src
305- inc tmp0+1
306- clc
307-skip_src
308-
309- jsr Add40Tmp1
310-
311- dex
312- bne loop_y
313- rts
314-.)
315-
316-
317-DisplayMakeShiftedLogo
318-.(
319- ldx #100
320-loop_y
321- lda #0
322- sta OldByte
323- ldy #0
324-loop_x
325- lda (tmp0),y
326- pha
327- and #63
328- lsr
329- ora OldByte
330- ora #64
331- sta (tmp1),y
332-
333- pla
334- and #1
335- asl
336- asl
337- asl
338- asl
339- asl
340- sta OldByte
341-
342- iny
343- cpy #20
344- bne loop_x
345-
346- ldy #0
347- lda (tmp0),y
348- and #63
349- lsr
350- ora OldByte
351- ora #64
352- sta (tmp1),y
353-
354- clc
355- lda tmp0
356- adc #24
357- sta tmp0
358- bcc skip_src
359- inc tmp0+1
360- clc
361-skip_src
362-
363- lda tmp1
364- adc #24
365- sta tmp1
366- bcc skip_dst
367- inc tmp1+1
368-skip_dst
369-
370- dex
371- bne loop_y
372- rts
373-.)
374-
375-
376-
377-
378-; From _LogoBuffer
379-; To _ShiftedLogo
380-; Size: 20 bytes * 100 lines
381-_PreshiftSprite
382-.(
383- lda #<_LogoBuffer
384- sta tmp0+0
385- lda #>_LogoBuffer
386- sta tmp0+1
387-
388- lda #<_ShiftedLogo
389- sta tmp1+0
390- lda #>_ShiftedLogo
391- sta tmp1+1
392-
393- ldx #100
394-loop_y
395-
396- ; Copy the current scanline to the first line of the preshift buffer
397- ldy #0
398-loop_x
399- lda (tmp0),y
400- sta (tmp1),y
401- iny
402- cpy #20
403- bne loop_x
404-
405- lda #6
406- sta ShiftCount
407-loop_shift_count
408- ; Then shift this first entry to the second line of the preshift buffer
409- ; tmp1=current line
410- ; tmp2=second line
411- clc
412- lda tmp1+0
413- adc #20
414- sta tmp2+0
415- lda tmp1+1
416- adc #0
417- sta tmp2+1
418-
419- lda #0
420- sta OldByte
421- ldy #0
422-loop_shift_x
423- lda (tmp1),y
424- pha
425- and #63
426- lsr
427- ora OldByte
428- ora #64
429- sta (tmp2),y
430-
431- pla
432- and #1
433- asl
434- asl
435- asl
436- asl
437- asl
438- sta OldByte
439-
440- iny
441- cpy #20
442- bne loop_shift_x
443-
444- ldy #0
445- lda (tmp1),y
446- and #63
447- lsr
448- ora OldByte
449- ora #64
450- sta (tmp2),y
451-
452- lda tmp2+0
453- sta tmp1+0
454- lda tmp2+1
455- sta tmp1+1
456-
457- dec ShiftCount
458- bne loop_shift_count
459-
460-
461- ; Get the next line of the logo
462- clc
463- lda tmp0+0
464- adc #20
465- sta tmp0+0
466- lda tmp0+1
467- adc #0
468- sta tmp0+1
469-
470- dex
471- bne loop_y
472-
473- rts
474-.)
475-
476-
477-
478-
479-; From _LogoBuffer
480-; To _ShiftedLogo
481-; Size: 20 bytes * 100 lines
482-_PreshiftSprite_WorkingSimpleCopy
483-.(
484- lda #<_LogoBuffer
485- sta tmp0+0
486- lda #>_LogoBuffer
487- sta tmp0+1
488-
489- lda #<_ShiftedLogo
490- sta tmp1+0
491- lda #>_ShiftedLogo
492- sta tmp1+1
493-
494- ldx #100
495-loop_y
496-
497- ldy #0
498-loop_x
499- lda (tmp0),y
500- sta (tmp1),y
501-
502- iny
503- cpy #20
504- bne loop_x
505-
506- clc
507- lda tmp0+0
508- adc #20
509- sta tmp0+0
510- lda tmp0+1
511- adc #0
512- sta tmp0+1
513-
514- clc
515- lda tmp1+0
516- adc #20*6
517- sta tmp1+0
518- lda tmp1+1
519- adc #0
520- sta tmp1+1
521-
522- dex
523- bne loop_y
524-
525- rts
526-.)
527-
528-
529-CrossWordCount .byt 0
530-CrossWordXPos .byt 0
531-CrossWordYPos .byt 0
532-CrossWordDirection .byt 0
533-
534-DisplayCrossWord
535- ;jmp DisplayHorizontalWord
536-.(
537- lda #<$a000+40*57
538- sta tmp1+0
539- lda #>$a000+40*57
540- sta tmp1+1
541-
542- ldy #0
543- lda (tmp0),y
544- sta CrossWordXPos
545- iny
546- lda (tmp0),y
547- sta CrossWordYPos
548-
549- ; Add xpos
550- clc
551- lda tmp1+0
552- adc CrossWordXPos
553- sta tmp1+0
554- lda tmp1+1
555- adc #0
556- sta tmp1+1
557-
558- ; Add ypos
559-loop_y_inc
560- dec CrossWordYPos
561- bmi end_y_inc
562- clc
563- lda tmp1+0
564- adc #40*6
565- sta tmp1+0
566- lda tmp1+1
567- adc #0
568- sta tmp1+1
569- jmp loop_y_inc
570-end_y_inc
571-
572- clc
573- lda tmp0+0
574- adc #2
575- sta tmp0+0
576- lda tmp0+1
577- adc #0
578- sta tmp0+1
579-
580- ldy #0
581-loop_car
582- ; Get ASCII value
583- lda (tmp0),y
584- beq done
585-
586- ; The font starts at the space character, and is stored per scanline (96 bytes wide)
587- clc
588- adc #<_Font6x6-32
589- sta tmp2+0
590- lda #0
591- adc #>_Font6x6-32
592- sta tmp2+1
593-
594- lda CrossWordDirection
595- bne vertical_move
596-horizontal_move
597- clc
598- lda tmp1+0
599- sta tmp3+0
600- adc #1
601- sta tmp1+0
602- lda tmp1+1
603- sta tmp3+1
604- adc #0
605- sta tmp1+1
606- jmp draw_char
607-vertical_move
608- clc
609- lda tmp1+0
610- sta tmp3+0
611- adc #40*6
612- sta tmp1+0
613- lda tmp1+1
614- sta tmp3+1
615- adc #0
616- sta tmp1+1
617- jmp draw_char
618-
619-draw_char
620- ldy #0
621- ldx #6
622-loop_y
623- lda (tmp2),y
624- eor #128
625- sta (tmp3),y
626-
627- clc
628- lda tmp2+0
629- adc #96
630- sta tmp2+0
631- lda tmp2+1
632- adc #0
633- sta tmp2+1
634-
635- clc
636- lda tmp3+0
637- adc #40
638- sta tmp3+0
639- lda tmp3+1
640- adc #0
641- sta tmp3+1
642-
643- dex
644- bne loop_y
645-
646- ;jsr _VSync
647- jsr _VSync
648- jsr _VSync
649-
650- jsr IncTmp0
651-
652- jmp loop_car
653-done
654- jsr IncTmp0
655- rts
656-.)
657-
658-
659-
660-_DrawCrossWords
661-.(
662- lda #<CrossWordsHorizontal
663- sta tmp0+0
664- lda #>CrossWordsHorizontal
665- sta tmp0+1
666-
667- lda #0
668- sta CrossWordDirection
669-
670- lda #16
671- sta CrossWordCount
672-loop_horizontal
673- jsr DisplayCrossWord
674- dec CrossWordCount
675- bne loop_horizontal
676-
677- lda #1
678- sta CrossWordDirection
679-
680- lda #18
681- sta CrossWordCount
682-loop_vertical
683- jsr DisplayCrossWord
684- dec CrossWordCount
685- bne loop_vertical
686-
687- rts
688-.)
689-
690-
691-CrossWordsHorizontal
692- .BYT 8,10,"APANBEPAN",0
693- .BYT 24,20,"#ATARI(FR|SCNE)",0
694- .BYT 20,16,"BOOZEDESIGN",0
695- .BYT 23,22,"CENSORDESIGN",0
696- .BYT 12,19,"CYG^BLABLA",0
697- .BYT 22,18,"HOAXERS",0
698- .BYT 30,4,"EXCESS",0
699- .BYT 2,16,"KVASIGEN",0
700- .BYT 17,4,"LOONIES",0
701- .BYT 3,8,"NOSFE",0
702- .BYT 1,13,"OFENCE",0
703- .BYT 15,6,"OUTRACKS",0
704- .BYT 21,1,"PENUMBRA",0
705- .BYT 16,12,"PLAYPSYCHO",0
706- .BYT 27,14,"YOUTHUPRISING",0
707- .BYT 28,6,"TUFS",0
708-
709-CrossWordsVertical
710- .BYT 32,9,"BAUDSURFER^RSI",0
711- .BYT 28,8,"BOOZOHOLICS",0
712- .BYT 4,11,"CONTRAZ",0
713- .BYT 16,8,"CONSPIRACY",0
714- .BYT 24,5,"DARKLIGHT",0
715- .BYT 13,9,"DEADROMAN",0
716- .BYT 34,8,"KEYBOARDERS",0
717- .BYT 9,9,"EPHIDRENA",0
718- .BYT 30,6,"FAIRLIGHT",0
719- .BYT 6,8,"FNUQUE",0
720- .BYT 37,9,"GENESISPROJECT",0
721- .BYT 35,2,"INSANE",0
722- .BYT 22,0,"KEWLERS",0
723- .BYT 3,3,"OXYRON",0
724- .BYT 11,8,"PANDACUBE",0
725- .BYT 18,6,"RESISTANCE",0
726- .BYT 20,11,"SPACEBALLS",0
727- .BYT 39,5,"WRATHDESIGN",0
728-
729- .byt 0,0,"A",0
730- .byt 0,0,"A",0
731- .byt 0,0,"A",0
732- .byt 0,0,"A",0
733-
734-
735- .byt "Twilighte",0
736- .byt "Chema",0
737- .BYT 21,2,"PWP",0
738-
739-
740-LogoFrameCounter .byt 0
741-LogoHeight .byt 0
742-LogoWidth .byt 0
743-
744-
745-
746-_ShowSmallDefenceForce
747- lda #<_PictureLoadingBuffer+20*100
748- sta tmp0+0
749- lda #>_PictureLoadingBuffer+20*100
750- sta tmp0+1
751-
752- lda #<$a000+(52+22)*40+10
753- sta tmp1+0
754- lda #>$a000+(52+22)*40+10
755- sta tmp1+1
756-
757- lda #20
758- sta LogoWidth
759-
760- lda #100
761- sta LogoHeight
762-
763- jmp ShowDefenceForce
764-
765-_ShowLargeDefenceForce
766-.(
767- lda #<_PictureLoadingBuffer
768- sta tmp0+0
769- lda #>_PictureLoadingBuffer
770- sta tmp0+1
771-
772- lda #<$a000
773- sta tmp1+0
774- lda #>$a000
775- sta tmp1+1
776-
777- lda #40
778- sta LogoWidth
779-
780- lda #200
781- sta LogoHeight
782-
783-+ShowDefenceForce
784- ldx LogoHeight
785-loop_y
786- ldy #0
787-loop_x
788- lda (tmp0),y
789- sta (tmp1),y
790- iny
791- cpy LogoWidth
792- bne loop_x
793-
794- cpx #0
795- beq end_blue
796- cpx #1
797- beq end_cyan
798- cpx #2
799- beq end_white
800-
801- lda #16+7
802- ldy #40*3
803- sta (tmp1),y
804-end_white
805-
806- lda #16+6
807- ldy #40*2
808- sta (tmp1),y
809-end_cyan
810-
811- lda #16+4
812- ldy #40*1
813- sta (tmp1),y
814-end_blue
815-
816- clc
817- lda tmp0
818- adc LogoWidth
819- sta tmp0
820- bcc skip_src
821- inc tmp0+1
822-skip_src
823-
824- jsr Add40Tmp1
825-
826- jsr _VSync
827-
828- dex
829- bne loop_y
830-
831- rts
832-.)
833-
834-
835-
836-_ShowTinyKindergardenLogo
837- lda #<_PictureLoadBuffer60x50+10*151
838- sta tmp3+0
839- lda #>_PictureLoadBuffer60x50+10*151
840- sta tmp3+1
841-
842-
843-
844- lda #<$a000+(52+22+38+13)*40+10+5
845- sta tmp2+0
846- lda #>$a000+(52+22+38+13)*40+10+5
847- sta tmp2+1
848-
849- lda #10
850- sta LogoWidth
851-
852- lda #13
853- sta LogoHeight
854-
855- jmp ShowKindergardenLogo
856-
857-_ShowSmallKindergardenLogo
858- lda #<_PictureLoadingBuffer+20*271
859- sta tmp3+0
860- lda #>_PictureLoadingBuffer+20*271
861- sta tmp3+1
862-
863- lda #<$a000+40*(100)+10
864- sta tmp2+0
865- lda #>$a000+40*(100)+10
866- sta tmp2+1
867-
868- lda #20
869- sta LogoWidth
870-
871- lda #26
872- sta LogoHeight
873-
874- jmp ShowKindergardenLogo
875-
876-_ShowLargeKindergardenLogo
877- ;jmp _ShowKindergardenLogo
878-.(
879- lda #<_PictureLoadingBuffer
880- sta tmp3+0
881- lda #>_PictureLoadingBuffer
882- sta tmp3+1
883-
884- lda #<$a000+40*52
885- sta tmp2+0
886- lda #>$a000+40*52
887- sta tmp2+1
888-
889- lda #40
890- sta LogoWidth
891-
892- lda #53
893- sta LogoHeight
894-
895-+ShowKindergardenLogo
896- ldx #1
897-loop_frame
898- stx LogoFrameCounter
899-
900- sec
901- lda tmp2+0
902- sbc #40
903- sta tmp1+0
904- sta tmp2+0
905- lda tmp2+1
906- sbc #0
907- sta tmp1+1
908- sta tmp2+1
909-
910- lda tmp3+0
911- sta tmp0+0
912- lda tmp3+1
913- sta tmp0+1
914-
915-loop_y
916- ldy #0
917-loop_x
918- lda (tmp0),y
919- sta (tmp1),y
920- iny
921- cpy LogoWidth
922- bne loop_x
923-
924- clc
925- lda tmp0
926- adc LogoWidth
927- sta tmp0
928- bcc skip_src
929- inc tmp0+1
930-skip_src
931-
932- jsr Add40Tmp1
933-
934- dex
935- bne loop_y
936-
937- jsr _VSync
938-
939- ldx LogoFrameCounter
940- inx
941- cpx LogoHeight
942- bne loop_frame
943-
944- rts
945-.)
946-
947-
948-
949-_HideLargeKindergardenLogo
950- ;jmp _HideLargeKindergardenLogo
951-.(
952- lda #53
953- sta LogoFrameCounter
954-
955-loop_frame
956- lda #<$a000+40*52
957- sta tmp0+0
958- lda #>$a000+40*52
959- sta tmp0+1
960-
961- ldx #52
962-loop_y
963-
964- sec
965- lda tmp0+0
966- sta tmp1+0
967- sbc #40
968- sta tmp0+0
969-
970- lda tmp0+1
971- sta tmp1+1
972- sbc #0
973- sta tmp0+1
974-
975- ldy #0
976-loop_x
977- lda (tmp0),y
978- sta (tmp1),y
979- iny
980- cpy #40
981- bne loop_x
982-
983- dex
984- bne loop_y
985-
986- jsr _VSync
987-
988- dec LogoFrameCounter
989- bne loop_frame
990-
991- rts
992-.)
993-
994-
995-
996-_PatchAttributesBirthdayCake
997-.(
998- ; column 22, row 1, 31 high
999- lda #<_PictureLoadingBuffer+(40*1)
1000- sta tmp1+0
1001- lda #>_PictureLoadingBuffer+(40*1)
1002- sta tmp1+1
1003-
1004- ldx #31
1005-loop
1006- lda #64
1007- ldy #22
1008- sta (tmp1),y
1009-
1010- jsr Add40Tmp1
1011-
1012- dex
1013- bne loop
1014- rts
1015-.)
1016-
1017-
1018-_BadeStampColors
1019- .byt 7
1020- .byt 7
1021- .byt 6
1022- .byt 7
1023- .byt 6
1024- .byt 6
1025- .byt 2
1026- .byt 6
1027- .byt 2
1028- .byt 2
1029- .byt 5
1030- .byt 2
1031- .byt 5
1032- .byt 5
1033- .byt 2
1034- .byt 5
1035- .byt 2
1036- .byt 2
1037- .byt 6
1038- .byt 2
1039- .byt 6
1040- .byt 6
1041- .byt 7
1042- .byt 6
1043- .byt 6
1044- .byt 7
1045- .byt 7
1046- .byt 6
1047- .byt 7
1048- .byt 7
1049- .byt 7
1050- .byt 7
1051- .byt 7
1052- .byt 7
1053- .byt 3
1054- .byt 7
1055- .byt 7
1056- .byt 3
1057- .byt 7
1058- .byt 3
1059- .byt 3
1060- .byt 7
1061- .byt 7
1062- .byt 3
1063- .byt 3
1064- .byt 3
1065- .byt 3
1066- .byt 7
1067- .byt 3
1068- .byt 3
1069- .byt 7
1070- .byt 3
1071- .byt 7
1072- .byt 7
1073- .byt 7
1074- .byt 7
1075- .byt 7
1076- .byt 7
1077- .byt 7
1078- .byt 7
1079- .byt 7
1080- .byt 7
1081- .byt 7
1082- .byt 7
1083-
1084-
1085-
--- users/dbug/games/GlobalGameJam2016/code/player.s (revision 1363)
+++ users/dbug/games/GlobalGameJam2016/code/player.s (nonexistent)
@@ -1,681 +0,0 @@
1-; To check: AYC
2-; http://cpcwiki.eu/index.php/AYC
3-
4-#include "floppy_description.h"
5-
6- .zero
7-
8-_DecodedByte .dsb 1 ; Byte being currently decoded from the MYM stream
9-_DecodeBitCounter .dsb 1 ; Number of bits we can read in the current byte
10-_DecodedResult .dsb 1 ; What is returned by the 'read bits' function
11-
12-_CurrentAYRegister .dsb 1 ; Contains the number of the register being decoded
13-
14-_RegisterBufferHigh .dsb 1 ; Points to the high byte of the decoded register buffer, increment to move to the next register
15-_BufferFrameOffset .dsb 1 ; From 0 to 127, used when filling the decoded register buffer
16-
17-_MusicResetCounter .dsb 2 ; Contains the number of rows to play before reseting
18-
19-_CurrentFrame .dsb 1 ; From 0 to 255 and then cycles... the index of the frame to play this vbl
20-
21-_PlayerVbl .dsb 1
22-
23-_FrameLoadBalancer .dsb 1 ; We depack a new frame every 9 VBLs, this way the 14 registers are evenly depacked over 128 frames
24-
25-_MusicTimer ; So we can 'wait' a particular position of the music
26-_MusicTimerLow .dsb 1
27-_MusicTimerHigh .dsb 1
28-
29- .text
30-
31-#define VIA_1 $30f
32-#define VIA_2 $30c
33-
34-#define _MusicData $c000
35-
36-_PlayerCount .byt 0
37-_MusicPlaying .byt 0
38-
39-
40-;
41-; Current PSG values during unpacking
42-;
43-_PlayerRegValues
44-_RegisterChanAFrequency
45- ; Chanel A Frequency
46- .byt 8
47- .byt 4
48-
49-_RegisterChanBFrequency
50- ; Chanel B Frequency
51- .byt 8
52- .byt 4
53-
54-_RegisterChanCFrequency
55- ; Chanel C Frequency
56- .byt 8
57- .byt 4
58-
59-_RegisterChanNoiseFrequency
60- ; Chanel sound generator
61- .byt 5
62-
63- ; select
64- .byt 8
65-
66- ; Volume A,B,C
67-_RegisterChanAVolume
68- .byt 5
69-_RegisterChanBVolume
70- .byt 5
71-_RegisterChanCVolume
72- .byt 5
73-
74- ; Wave period
75- .byt 8
76- .byt 8
77-
78- ; Wave form
79- .byt 8
80-
81-_PlayerRegCurrentValue .byt 0
82-
83-
84-_Mym_MusicStart
85-.(
86- ; The two first bytes of the MYM music is the number of rows in the music
87- ; We decrement that at each frame, and when we reach zero, time to start again.
88- ldx _MusicData+0
89- stx _MusicResetCounter+0
90- ldx _MusicData+1
91- inx
92- stx _MusicResetCounter+1
93-
94- .(
95- ; Initialize the read bit counter
96- lda #<(_MusicData+2)
97- sta __auto_music_ptr+1
98- lda #>(_MusicData+2)
99- sta __auto_music_ptr+2
100-
101- lda #1
102- sta _DecodeBitCounter
103-
104- ; Clear all data
105- lda #0
106- sta _DecodedResult
107- sta _DecodedByte
108- sta _PlayerVbl
109- sta _PlayerRegCurrentValue
110- sta _BufferFrameOffset
111- sta _PlayerCount
112- sta _CurrentAYRegister
113- sta _CurrentFrame
114- sta _MusicTimerLow
115- sta _MusicTimerHigh
116-
117- ldx #14
118-loop_init
119- dex
120- sta _PlayerRegValues,x
121- bne loop_init
122- .)
123-
124- ;
125- ; Unpack the 128 first register frames
126- ;
127- .(
128- lda #>_PlayerBuffer
129- sta _RegisterBufferHigh
130-
131- ldx #0
132-unpack_block_loop
133- stx _CurrentAYRegister
134-
135- ; Unpack that register
136- jsr _PlayerUnpackRegister2
137-
138- ; Next register
139- ldx _CurrentAYRegister
140- inx
141- cpx #14
142- bne unpack_block_loop
143- .)
144-
145- lda #128
146- sta _PlayerVbl+0
147-
148- lda #0
149- sta _PlayerCount
150- sta _CurrentAYRegister
151- sta _CurrentFrame
152-
153- lda #9
154- sta _FrameLoadBalancer
155-
156- lda #1
157- sta _MusicPlaying
158-
159- ;
160- ; Install the IRQ
161- ;
162- php
163- sei
164- lda #<_Mym_PlayFrame
165- sta _InterruptCallBack_3+1
166- lda #>_Mym_PlayFrame
167- sta _InterruptCallBack_3+2
168-#ifdef ENABLE_TIMING_DEBUGGING
169- jsr _InitializeTimings
170-#endif
171- plp
172-
173- rts
174-.)
175-
176-
177-_Mym_MusicStop
178-.(
179- ; Indicate the main code that the music is finished
180- lda #0
181- sta _MusicPlaying
182-
183- ; Disable the IRQ so it does not conflict or cause weird things
184- php
185- sei
186- lda #<_DoNothing
187- sta _InterruptCallBack_3+1
188- lda #>_DoNothing
189- sta _InterruptCallBack_3+2
190- plp
191-
192- ; Cut the sound so it does not sounds like a dying cat
193-
194- ; y=register number
195- ; x=value to write
196- ldy #7 ; Control register
197- ldx #$FF
198- jsr _PsgPlayRegister
199-
200- ldy #8 ; Volume A
201- ldx #0
202- jsr _PsgPlayRegister
203-
204- ldy #9 ; Volume B
205- ldx #0
206- jsr _PsgPlayRegister
207-
208- ldy #10 ; Volume C
209- ldx #0
210- jsr _PsgPlayRegister
211- rts
212-.)
213-
214-_Mym_PlayFrame
215-.(
216-#ifdef ENABLE_TIMING_DEBUGGING
217- jsr _DisplayTimings
218-#endif
219-
220- .(
221- inc _MusicTimerLow
222- bne skip
223- inc _MusicTimerHigh
224-skip
225- .)
226-
227- ;
228- ; Check for end of music
229- ; CountZero: $81,$0d
230- dec _MusicResetCounter+0
231- bne music_contines
232- dec _MusicResetCounter+1
233- bne music_contines
234-
235-music_resets
236- jmp _Mym_MusicStop
237-
238-music_contines
239-
240- ;
241- ; Play a frame of 14 registers
242- ;
243- .(
244- lda _CurrentFrame
245- sta _auto_psg_play_read+1
246- lda #>_PlayerBuffer
247- sta _auto_psg_play_read+2
248-
249- ldy #0
250-register_loop
251-
252-_auto_psg_play_read
253- ldx _PlayerBuffer
254-
255- ; y=register number
256- ; x=value to write
257- jsr _PsgPlayRegister
258-
259- inc _auto_psg_play_read+2
260- iny
261- cpy #14
262- bne register_loop
263- .)
264-
265-
266- inc _CurrentFrame
267- inc _PlayerCount
268-
269- lda _CurrentAYRegister
270- cmp #14
271- bcs end_reg
272-
273- .(
274- dec _FrameLoadBalancer
275- bne end
276-
277- jsr _PlayerUnpackRegister
278- inc _CurrentAYRegister
279- lda #9
280- sta _FrameLoadBalancer
281-end
282- rts
283- .)
284-
285-end_reg
286- .(
287- lda _PlayerCount
288- cmp #128
289- bcc skip
290-
291- lda #0
292- sta _CurrentAYRegister
293- sta _PlayerCount
294- lda #9
295- sta _FrameLoadBalancer
296-
297- clc
298- lda _PlayerVbl+0
299- adc #128
300- sta _PlayerVbl+0
301-skip
302- .)
303-
304- rts
305-.)
306-
307-
308-; y=register number
309-; x=value to write
310-_PsgPlayRegister
311-.(
312- sty VIA_1
313- txa
314-
315- pha
316- lda VIA_2
317- ora #$EE ; $EE 238 11101110
318- sta VIA_2
319-
320- and #$11 ; $11 17 00010001
321- ora #$CC ; $CC 204 11001100
322- sta VIA_2
323-
324- tax
325- pla
326- sta VIA_1
327- txa
328- ora #$EC ; $EC 236 11101100
329- sta VIA_2
330-
331- and #$11 ; $11 17 00010001
332- ora #$CC ; $CC 204 11001100
333- sta VIA_2
334-
335- rts
336-.)
337-
338-
339-
340-;
341-; Initialise X with the number of bits to read
342-; Y is not modifier
343-;
344-_ReadBits
345-.(
346- lda #0
347- sta _DecodedResult
348-
349- ; Will iterate X times (number of bits to read)
350-loop_read_bits
351-
352- dec _DecodeBitCounter
353- beq get_next_byte
354-
355-shift_bit
356- asl _DecodedByte
357- rol _DecodedResult
358-
359- dex
360- bne loop_read_bits
361- rts
362-
363-get_next_byte
364- ; reset mask
365- lda #8
366- sta _DecodeBitCounter
367-
368- ; fetch a new byte, and increment the adress.
369-+__auto_music_ptr
370- lda _MusicData+2
371- sta _DecodedByte
372-
373- inc __auto_music_ptr+1
374- bne shift_bit
375- inc __auto_music_ptr+2
376- jmp shift_bit
377-.)
378-
379-
380-
381-
382-_PlayerUnpackRegister
383- lda #>_PlayerBuffer
384- clc
385- adc _CurrentAYRegister
386- sta _RegisterBufferHigh
387-_PlayerUnpackRegister2
388- ;
389- ; Init register bit count and current value
390- ;
391- ldx _CurrentAYRegister
392- lda _PlayerRegValues,x
393- sta _PlayerRegCurrentValue
394-
395-
396- ;
397- ; Check if it's packed or not
398- ; and call adequate routine...
399- ;
400- ldx #1
401- jsr _ReadBits
402- ldx _DecodedResult
403- bne DecompressFragment
404-
405-
406-UnchangedFragment
407-.(
408- ;
409- ; No change at all, just repeat '_PlayerRegCurrentValue' 128 times
410- ;
411- lda _RegisterBufferHigh ; highpart of buffer adress + register number
412- sta __auto_copy_unchanged_write+2
413-
414- ldx #128 ; 128 iterations
415- lda _PlayerRegCurrentValue ; Value to write
416-
417- ldy _PlayerVbl
418-
419-repeat_loop
420-__auto_copy_unchanged_write
421- sta _PlayerBuffer,y
422- iny
423- dex
424- bne repeat_loop
425-.)
426-
427- jmp player_main_return
428-
429-
430-player_main_return
431- ; Write back register current value
432- ldx _CurrentAYRegister
433- lda _PlayerRegCurrentValue
434- sta _PlayerRegValues,x
435-
436- ; Move to the next register buffer
437- inc _RegisterBufferHigh
438- rts
439-
440-
441-
442-
443-DecompressFragment
444- lda _PlayerVbl ; Either 0 or 128 at this point else we have a problem...
445- sta _BufferFrameOffset
446-
447-decompressFragmentLoop
448-
449-player_copy_packed_loop
450- ; Check packing method
451- ldx #1
452- jsr _ReadBits
453-
454- ldx _DecodedResult
455- bne PlayerNotCopyLast
456-
457-UnchangedRegister
458-.(
459- ; We just copy the current value 128 times
460- lda _RegisterBufferHigh ; highpart of buffer adress + register number
461- sta __auto_player_copy_last+2
462-
463- ldx _BufferFrameOffset ; Value between 00 and 7f
464- lda _PlayerRegCurrentValue ; Value to copy
465-__auto_player_copy_last
466- sta _PlayerBuffer,x
467-
468- inc _BufferFrameOffset
469-.)
470-
471-
472-player_return
473-
474- ; Check end of loop
475- lda _BufferFrameOffset
476- and #127
477- bne decompressFragmentLoop
478-
479- jmp player_main_return
480-
481-
482-PlayerNotCopyLast
483- ; Check packing method
484- ldx #1
485- jsr _ReadBits
486-
487- ldx _DecodedResult
488- beq DecompressWithOffset
489-
490-ReadNewRegisterValue
491- ; Read new register value (variable bit count)
492- ldx _CurrentAYRegister
493- lda _PlayerRegBits,x
494- tax
495- jsr _ReadBits
496- ldx _DecodedResult
497- stx _PlayerRegCurrentValue
498-
499- ; Copy to stream
500- lda _RegisterBufferHigh ; highpart of buffer adress + register number
501- sta __auto_player_read_new+2
502-
503- ldx _BufferFrameOffset ; Value between 00 and 7f
504- lda _PlayerRegCurrentValue ; New value to write
505-__auto_player_read_new
506- sta _PlayerBuffer,x
507-
508- inc _BufferFrameOffset
509- jmp player_return
510-
511-
512-
513-
514-DecompressWithOffset
515-.(
516- ; Read Offset (0 to 127)
517- ldx #7
518- jsr _ReadBits
519-
520- lda _RegisterBufferHigh ; highpart of buffer adress + register number
521- sta __auto_write+2 ; Write adress
522- sta __auto_read+2 ; Read adress
523-
524- ; Compute wrap around offset...
525- lda _BufferFrameOffset ; between 0 and 255
526- clc
527- adc _DecodedResult ; + Offset Between 00 and 7f
528- sec
529- sbc #128 ; -128
530- tay
531-
532- ; Read count (7 bits)
533- ldx #7
534- jsr _ReadBits
535-
536- inc _DecodedResult ; 1 to 129
537-
538-
539- ldx _BufferFrameOffset
540-
541-player_copy_offset_loop
542-
543-__auto_read
544- lda _PlayerBuffer,y ; Y for reading
545- iny
546-
547-__auto_write
548- sta _PlayerBuffer,x ; X for writing
549-
550- inx
551- dec _DecodedResult
552- bne player_copy_offset_loop
553-
554- stx _BufferFrameOffset
555- sta _PlayerRegCurrentValue
556-
557- jmp player_return
558-.)
559-
560-
561-
562-;
563-; Size in bits of each PSG register
564-;
565-_PlayerRegBits
566- ; Chanel A Frequency
567- .byt 8
568- .byt 4
569-
570- ; Chanel B Frequency
571- .byt 8
572- .byt 4
573-
574- ; Chanel C Frequency
575- .byt 8
576- .byt 4
577-
578- ; Chanel sound generator
579- .byt 5
580-
581- ; select
582- .byt 8
583-
584- ; Volume A,B,C
585- .byt 5
586- .byt 5
587- .byt 5
588-
589- ; Wave period
590- .byt 8
591- .byt 8
592-
593- ; Wave form
594- .byt 8
595-
596-
597-
598-
599-#ifdef ENABLE_TIMING_DEBUGGING
600-
601-#define TIMING_ADDRESS $bb80+40*25+10
602-_InitializeTimings
603- lda #"0"
604- ; Minute
605- sta TIMING_ADDRESS+0
606- sta TIMING_ADDRESS+1
607- ; Second
608- sta TIMING_ADDRESS+3
609- sta TIMING_ADDRESS+4
610- ; Frame (50th of a second)
611- sta TIMING_ADDRESS+6
612- sta TIMING_ADDRESS+7
613- lda #"'"
614- sta TIMING_ADDRESS+2
615- lda #34
616- sta TIMING_ADDRESS+5
617- lda #16+1
618- sta TIMING_ADDRESS-1
619- lda #16+0
620- sta TIMING_ADDRESS+9
621- rts
622-
623-_DisplayTimings
624-.(
625- ; Increment the low frame value
626- inc TIMING_ADDRESS+7
627- ldx TIMING_ADDRESS+7
628- cpx #":"
629- bne done
630- ldx #"0"
631- stx TIMING_ADDRESS+7
632-
633- ; Increment the high frame value
634- inc TIMING_ADDRESS+6
635- ldx TIMING_ADDRESS+6
636- cpx #"5"
637- bne done
638- ldx #"0"
639- stx TIMING_ADDRESS+6
640- stx TIMING_ADDRESS+7
641-
642- ; Increment the low second value
643- inc TIMING_ADDRESS+4
644- ldx TIMING_ADDRESS+4
645- cpx #":"
646- bne done
647- ldx #"0"
648- stx TIMING_ADDRESS+4
649-
650- ; Increment the high second value
651- inc TIMING_ADDRESS+3
652- ldx TIMING_ADDRESS+3
653- cpx #"6"
654- bne done
655- ldx #"0"
656- stx TIMING_ADDRESS+3
657- stx TIMING_ADDRESS+4
658-
659- ; Increment the low minute value
660- inc TIMING_ADDRESS+1
661- ldx TIMING_ADDRESS+1
662- cpx #":"
663- bne done
664- ldx #"0"
665- stx TIMING_ADDRESS+1
666-
667- ; Increment the high minute value
668- inc TIMING_ADDRESS+0
669- ldx TIMING_ADDRESS+0
670- cpx #"6"
671- bne done
672- ldx #"0"
673- stx TIMING_ADDRESS+0
674- stx TIMING_ADDRESS+1
675-
676-done
677- rts
678-.)
679-#endif
680-
681-
--- users/dbug/games/GlobalGameJam2016/code/misc_stuff.c (revision 1363)
+++ users/dbug/games/GlobalGameJam2016/code/misc_stuff.c (nonexistent)
@@ -1,167 +0,0 @@
1-
2-
3-
4-#ifdef ENABLE_FUNCOM_LOGO_INTRO
5- // Load the Funcom Logo and put it on the screen hidden
6- {
7- char* screen;
8- int y;
9-
10- LoaderApiEntryIndex=LOADER_FUNCOM_LOGO;
11- LoaderApiAddress=(void*)0x400;
12- SetLoadAddress();
13- LoadFile();
14-
15- screen=(char*)0xa000;
16- for (y=0;y<200;y++)
17- {
18- screen[0]=0; // Black ink
19- memcpy(screen+1,LoaderApiAddress+1,39);
20- screen+=40;
21- LoaderApiAddress+=40;
22- }
23- }
24-#endif
25-
26- /*
27- // Check the keyboard status
28- while (1)
29- {
30- unsigned char* screen=(unsigned char*)0xbb80+40*25;
31- if (KeyboardState & 1) *screen++=16+1; else *screen++=16+2;
32- if (KeyboardState & 2) *screen++=16+1; else *screen++=16+2;
33- if (KeyboardState & 4) *screen++=16+1; else *screen++=16+2;
34- if (KeyboardState & 8) *screen++=16+1; else *screen++=16+2;
35- if (KeyboardState & 16) *screen++=16+1; else *screen++=16+2;
36- }
37- */
38-
39- /*
40-// Entry #5 '..\build\files\FuncomJingle.raw'
41-// - Loads at address 1024 starts on track 1 sector 6 and is 22 sectors long (5610 compressed bytes: 17% of 32918 bytes).
42- LoaderApiEntryIndex=LOADER_FUNCOM_JINGLE;
43- //LoaderApiAddress=PictureLoadingBuffer;
44- //SetLoadAddress();
45- LoadFile();
46- */
47-
48-#ifdef ENABLE_FUNCOM_JINGLE
49- // Play the digit
50- DigiPlayer_InstallIrq();
51-#endif
52-
53-#ifdef ENABLE_FUNCOM_LOGO_INTRO
54- // Show the funcom logo progressively while the sample plays
55- {
56- char* screen1;
57- char* screen2;
58- int y,i;
59-
60- screen1=(char*)0xa000;
61- screen2=(char*)0xa000+199*40;
62- for (y=0;y<100;y++)
63- {
64- screen1[40*0]=1; // Red ink
65- screen1[40*1]=3; // Yellow ink
66- screen1[40*2]=7; // White ink
67- screen1+=40;
68-
69- screen2[-40*2]=7; // White ink
70- screen2[-40*1]=3; // Yellow ink
71- screen2[-40*0]=1; // Red ink
72- screen2-=40;
73-
74- for (i=0;i<450;i++)
75- {
76-
77- }
78- }
79-
80- // Then all in yellow
81- screen1=(char*)0xa000;
82- for (y=0;y<200;y++)
83- {
84- screen1[40*0]=3; // Yellow ink
85- screen1+=40;
86- }
87-
88- // Then all in white
89- screen1=(char*)0xa000;
90- for (y=0;y<200;y++)
91- {
92- screen1[40*0]=7; // White ink
93- screen1+=40;
94- }
95-
96- // Then all in cyan
97- screen1=(char*)0xa000;
98- for (y=0;y<200;y++)
99- {
100- screen1[40*0]=6; // Cyan ink
101- screen1+=40;
102- }
103-
104- // Then all in blue
105- screen1=(char*)0xa000;
106- for (y=0;y<200;y++)
107- {
108- screen1[40*0]=4; // Blue ink
109- screen1+=40;
110- }
111-
112- }
113-#endif
114-
115-
116-
117- {
118-#ifdef ENABLE_GAMEJAM_LOGO
119- LoaderApiEntryIndex=LOADER_GAMEJAM_LOGO;
120- LoaderApiAddress=BufferPicture1;
121- SetLoadAddress();
122- LoadFile();
123-#endif
124-
125-#ifdef ENABLE_FUNCOM_LOGO
126- LoaderApiEntryIndex=LOADER_FUNCOM_LOGO;
127- LoaderApiAddress=BufferPicture2;
128- SetLoadAddress();
129- LoadFile();
130-#endif
131-
132-#ifdef ENABLE_VALP_ANIMATION
133- LoaderApiEntryIndex=LOADER_VALP_OUTLINE;
134- LoaderApiAddress=BufferPicture3;
135- SetLoadAddress();
136- LoadFile();
137-#endif
138- }
139-
140- // And final forever loop
141- while(1)
142- {
143-#ifdef ENABLE_PRESS_FIRE_TO_START
144- ShowPressFireMessage();
145-#endif
146-
147-#ifdef ENABLE_MAIN_MENU
148- ShowGameMenu();
149-#endif
150-
151- }
152-
153-
154-
155-
156-/*
157-
158-Funcom Jingle:
159-- 66398 bytes - 8 bits mono 8khz
160-- 32918 bytes - 4 bits modo 4khz
161-
162-Total amount of memory available:
163-from $400 to $9800 = 37888 bytes
164-
165-
166-*/
167-
--- users/dbug/games/GlobalGameJam2016/code/rasters.s (revision 1363)
+++ users/dbug/games/GlobalGameJam2016/code/rasters.s (nonexistent)
@@ -1,271 +0,0 @@
1-
2-
3-_BufferZ .dsb 200
4-_BufferPaper .dsb 200
5-_BufferInk .dsb 200
6-
7-
8-; Clear the raster color buffer
9-_RastersClearBuffer
10-;BreakPoint jmp BreakPoint
11- ldx #200 ; 200 entries in the buffer
12-RastersClearBufferLoop
13- lda #16 ; PAPER BLACK
14- sta _BufferPaper-1,x
15- lda #7 ; White INK
16- sta _BufferInk-1,x
17- lda #0 ; NULL Z
18- sta _BufferZ-1,x
19- ;
20- lda #16+4 ; PAPER BLUE
21- sta _BufferPaper-2,x
22- lda #7 ; White INK
23- sta _BufferInk-2,x
24- lda #0 ; NULL Z
25- sta _BufferZ-2,x
26-
27- dex
28- dex
29- bne RastersClearBufferLoop
30- rts
31-
32-
33-_RastersXOffset .byt 0
34-
35-; Display the content of the buffer
36-; onto the screen
37-_RastersDisplayBuffer
38- clc
39- lda #<$a000+40*55
40- adc _RastersXOffset
41- sta tmp0
42- lda #>$a000+40*55
43- adc #0
44- sta tmp0+1
45-
46- ldx #0
47-RastersDisplayBufferLoop
48- lda _BufferPaper,x
49- ldy #0
50- sta (tmp0),y
51- lda _BufferInk,x
52- ldy #1
53- sta (tmp0),y
54- inx
55-
56- lda _BufferPaper,x
57- ldy #40
58- sta (tmp0),y
59- lda _BufferInk,x
60- ldy #41
61- sta (tmp0),y
62- inx
63-
64- clc
65- lda tmp0
66- adc #80
67- sta tmp0
68- lda tmp0+1
69- adc #0
70- sta tmp0+1
71-
72- cpx #142
73- bne RastersDisplayBufferLoop
74- rts
75-
76-
77-
78-
79-
80-;typedef struct
81-;{
82-; unsigned char *ptr_table; +0
83-; unsigned char prof; +2
84-; unsigned char angle; +3
85-; unsigned char speed; +4
86-;}BIGRASTER;
87-
88-
89-_RasterZ .byt 0
90-_RasterPointerBig .word 0
91-
92-
93-_RastersDrawBig
94-;BreakPoint jmp BreakPoint
95-
96- lda _RasterPointerBig
97- sta tmp0
98- lda _RasterPointerBig+1
99- sta tmp0+1
100-
101- ; Get color table pointer
102- ldy #0
103- lda (tmp0),y
104- sta tmp1
105- iny
106- lda (tmp0),y
107- sta tmp1+1
108-
109- ; Read Z value
110- ldy #2
111- lda (tmp0),y
112- sta _RasterZ
113-
114- ; Get the angle, and increment it
115- iny
116- lda (tmp0),y ; read angle
117- tax
118- clc
119- iny
120- adc (tmp0),y ; add speed
121- dey
122- sta (tmp0),y ; store angle
123- lda _CosTable,x
124- lsr
125- clc
126- ;adc #20
127- tax
128-
129- ldy #0
130-RastersDrawBigLoop
131- ; Get color
132- lda (tmp1),y
133- beq RastersDrawBigEnd
134-
135-;BreakPoint jmp BreakPoint
136-
137- lda _RasterZ
138- cmp _BufferZ,x
139- bmi RastersDrawBigLoopSkipZ
140-
141- sta _BufferZ,x
142-
143- lda (tmp1),y
144- sta _BufferPaper,x
145-
146-RastersDrawBigLoopSkipZ
147- inx
148- iny
149- jmp RastersDrawBigLoop
150-
151-RastersDrawBigEnd
152- rts
153-
154-
155-
156-
157-;typedef struct
158-;{
159-; unsigned char *ptr_table; +0
160-; unsigned char prof; +2
161-; unsigned char y; +3
162-; unsigned char direction; +4
163-; unsigned char speed; +5
164-; unsigned char size_table; +6
165-;}SMALLRASTER;
166-
167-
168-_RasterPointerSmall .word 0
169-
170-
171-_RastersDrawSmall
172- ;BreakPoint jmp BreakPoint
173-
174- lda _RasterPointerSmall
175- sta tmp0
176- lda _RasterPointerSmall+1
177- sta tmp0+1
178-
179- ; Get color table pointer
180- ldy #0
181- lda (tmp0),y
182- sta tmp1
183- iny
184- lda (tmp0),y
185- sta tmp1+1
186-
187- ; Read Z value
188- ldy #2
189- lda (tmp0),y
190- sta _RasterZ
191-
192- ; Get the position, and move it
193- ldy #4
194- lda (tmp0),y ; read direction
195- bne RastersDrawSmallMoveUp
196-
197-RastersDrawSmallMoveDown
198- ; direction=0
199- clc
200- ldy #3
201- lda (tmp0),y ; read y
202- ldy #5
203- adc (tmp0),y ; speed
204- ldy #3
205- sta (tmp0),y ; write new y
206- tax
207- cmp #200-15
208- bcc RastersDrawSmallMoveEnd
209-
210-;BreakPoint jmp BreakPoint
211-
212- ldy #4
213- lda #1
214- sta (tmp0),y ; write direction
215-
216- jmp RastersDrawSmallMoveEnd
217-
218-RastersDrawSmallMoveUp
219- ; direction=1
220- sec
221- ldy #3
222- lda (tmp0),y ; read y
223- ldy #5
224- sbc (tmp0),y ; speed
225- ldy #3
226- sta (tmp0),y ; write new y
227- tax
228- cmp #5
229- bcs RastersDrawSmallMoveEnd
230-
231- ldy #4
232- lda #0
233- sta (tmp0),y ; write direction
234-
235- jmp RastersDrawSmallMoveEnd
236-
237-
238-RastersDrawSmallMoveEnd
239-
240-
241- lda (tmp0),y ; read y pos
242-
243- ldy #0
244-RastersDrawSmallLoop
245- ; Get color
246- lda (tmp1),y
247- beq RastersDrawSmallEnd
248-
249- lda _RasterZ
250- cmp _BufferZ,x
251- bmi RastersDrawSmallLoopSkipZ
252-
253- sta _BufferZ,x
254-
255- lda (tmp1),y
256- sta _BufferPaper,x
257- and #7
258- sta _BufferInk,x
259-
260-RastersDrawSmallLoopSkipZ
261- inx
262- iny
263- jmp RastersDrawSmallLoop
264-
265-RastersDrawSmallEnd
266- rts
267-
268-
269-
270-
271-; LAST LINE (to avoid missing instruction bug)
\ No newline at end of file
--- users/dbug/games/GlobalGameJam2016/design.txt (revision 1363)
+++ users/dbug/games/GlobalGameJam2016/design.txt (revision 1364)
@@ -1,4 +1,4 @@
1-GGJ Diversifiers
1+GGJ Diversifiers
22
33 For those jammers looking to level up or jam on hardcore we have our GGJ16 Diversifiers!
44
@@ -41,3 +41,111 @@
4141
4242
4343
44+--------------------------------------------
45+https://csdb.dk/forums/?roomid=11&topicid=26608&firstpost=30
46+--------------------------------------------
47+Ok guys, I finally tested the routine I did up there. Like said before, it only allows 14 bit input ($0000 to $41FF to be more accurate). The reason for this is that M needs one more bit. Ok, some people might want full 16 bit so here is a fixed routine which only has 3 opcodes more:
48+
49+ LDY #$00 ; R = 0
50+ LDX #$07
51+ CLC ; clear bit 16 of M
52+.loop
53+ TYA
54+ ORA stab-1,X
55+ STA THI ; (R ASL 8) | (D ASL 7)
56+ LDA MHI
57+ BCS .skip0 ; M >= 65536? then T <= M is always true
58+ CMP THI
59+ BCC .skip1 ; T <= M
60+.skip0
61+ SBC THI
62+ STA MHI ; M = M - T
63+ TYA
64+ ORA stab,x
65+ TAY ; R = R OR D
66+.skip1
67+ ASL MLO
68+ ROL MHI ; M = M ASL 1
69+ DEX
70+ BNE .loop
71+
72+ ; last iteration
73+
74+ BCS .skip2
75+ STY THI
76+ LDA MLO
77+ CMP #$80
78+ LDA MHI
79+ SBC THI
80+ BCC .skip3
81+.skip2
82+ INY ; R = R OR D (D is 1 here)
83+.skip3
84+ RTS
85+stab: .BYTE $01,$02,$04,$08,$10,$20,$40,$80
86+
87+This routine works perfectly for all values from $0000 to $FFFF. It even works better than BASIC V2 math which for example fails at INT(SQR(X)) sometimes :)
88+
89+In fact, my small BASIC program which was supposed to test the assembler sqrt routine failed at value 26569. It returned 162 there although 163*163 = 26569, so it said that my asm routine had failed although it was the BASIC V2 math routines which had failed :D
90+--------------------------------------------
91+https://csdb.dk/forums/?roomid=11&topicid=26608&firstpost=18
92+--------------------------------------------
93+(part 4: finally some asm)
94+
95+Taking a slightly modified version of the last pseudo code:
96+
97+R = 0
98+M = N
99+D = 128
100+for n = 7 to 0
101+{
102+ T = (R ASL 8) OR (D ASL 7)
103+ if (T <= M) then M=M-T : R = R OR D
104+ M = M ASL 1
105+ D = D LSR 1
106+}
107+
108+T can now be calculated quite easily. The high byte is simply R OR <some stuff> and the low byte is always 0 except for the last iteration where it is 128. The shifting of D is done via a table and voila, here is some 6510 code:
109+
110+ LDY #$00 ; R = 0
111+ LDX #$07
112+.loop
113+ TYA
114+ ORA stab-1,X
115+ STA THI ; (R ASL 8) | (D ASL 7)
116+ LDA MHI
117+ CMP THI
118+ BCC .skip1 ; T <= M
119+ SBC THI
120+ STA MHI ; M = M - T
121+ TYA
122+ ORA stab,x
123+ TAY ; R = R OR D
124+.skip1
125+ ASL MLO
126+ ROL MHI ; M = M ASL 1
127+ DEX
128+ BNE .loop
129+
130+ ; last iteration
131+
132+ STY THI
133+ LDA MLO
134+ CMP #$80
135+ LDA MHI
136+ SBC THI
137+ BCC .skip2
138+ INY ; R = R OR D (D is 1 here)
139+.skip2
140+ RTS
141+stab: .BYTE $01,$02,$04,$08,$10,$20,$40,$80
142+
143+I hope I didn't make any mistakes in that routine :)
144+
145+Input is MLO/MHI for N and output is Y-register for int(sqrt(N)).
146+
147+(Anyone here who would have guessed that a routine like that calculates a square root?)
148+--------------------------------------------
149+
150+
151+
Show on old repository browser