1 #include <arch/sms/SMSlib.h>
2 #include "bank2.h"
3
4 #define HOLEINSAT 506
5 /*
6 const unsigned char shft[192/2]={
7 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1,
8 1,1,1,1,1, 2,2,2,2,2, 2,2,2,2,2, 2,2,2,2,2,
9 3,3,3,3,3, 3,3,3,3,3,
10 4,4,4,4,4, 4,4,4,
11 5,5,5,5,5, 5,5,
12 6,6,6,6,6,
13 7,7,7,7,
14 8,8,8,
15 9,9,
16 10,10,
17 11,11,
18 12,12,
19 13,14,15,16,17,18,19,20,21,22,23}; */
20
21 const unsigned char shft[192/2]={
22 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,
23 1,1,1,1,2, 1,2,1,2,2, 2,2, 2,2,2,2,3,
24 2,3,2,3,3, 3,3,3,3,4,
25 /* 50 */
26 3,4,3,4,4, 4,4,5,
27 4,5,4,5,5, 5,6,
28 5,6,5,6,6,
29 /* 70 */
30 7,6,7,7,
31 8,7,8,
32 9,9,
33 10,10,
34 11,11,
35 12,12,
36 13,14,15,16,17,18,19,20,21,22,23};
37
38
39 unsigned char offs[192/2]; /* this will be zeroed by CRT0 */
40 unsigned char lineCnt,pole_x;
41
lineHandler(void)42 void lineHandler(void) {
43 SMS_setBGScrollX (offs[lineCnt++]);
44 }
45
main(void)46 void main(void) {
47 unsigned char i,pole_y;
48
49 // load assets into VRAM
50 SMS_loadPSGaidencompressedTiles (grass_reduced__tiles__psgcompr,0);
51 SMS_loadSTMcompressedTileMap (0, 0, grass_reduced__tilemap__stmcompr);
52 SMS_loadBGPalette (grass_reduced__palette__bin);
53 SMS_loadPSGaidencompressedTiles (pole__tiles__psgcompr,HOLEINSAT);
54 SMS_loadSpritePalette (pole__palette__bin);
55
56 // prepare for lineIRQ
57 SMS_setLineInterruptHandler(&lineHandler);
58 SMS_setLineCounter(1); /* we're updating every 2 scanlines... */
59 SMS_enableLineInterrupt();
60
61 // prepare sprites
62 SMS_initSprites();
63 for (i=0;i<5;i++)
64 SMS_addSprite(0,0,HOLEINSAT);
65 SMS_finalizeSprites();
66
67 // get this party started
68 SMS_VDPturnOnFeature(VDPFEATURE_LEFTCOLBLANK);
69 SMS_setSpriteMode(SPRITEMODE_TALL);
70 SMS_displayOn();
71 for (;;) {
72 SMS_waitForVBlank ();
73 SMS_disableLineInterrupt();
74 UNSAFE_SMS_copySpritestoSAT();
75 offs[0]+=shft[0];
76 SMS_setBGScrollX (offs[0]);
77 i=1;
78 do {
79 // offs[i++]+=shft[i];
80 offs[i]+=shft[i];
81 i++;
82 } while (i<(192/2));
83 lineCnt=1;
84
85 // move sprites
86 pole_y=52;
87 for (i=0;i<5;i++) {
88 SMS_updateSpritePosition(i,pole_x,pole_y);
89 pole_y+=16;
90 }
91 pole_x+=5;
92 SMS_enableLineInterrupt();
93 }
94 }
95