/[projet1]/public/oric/demos/PushingTheEnvelope/code/main.c
Defence Force logotype

Contents of /public/oric/demos/PushingTheEnvelope/code/main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1099 - (show annotations)
Sun Feb 2 12:27:33 2014 UTC (5 years, 9 months ago) by dbug
File MIME type: text/plain
File size: 3570 byte(s)
Complete source code and assets for Pushing The Envelope demo.
1 //
2 // This program simply display a picture on the hires screen
3 //
4 #include <lib.h>
5
6 #include "floppy_description.h"
7
8 // irq.s
9 extern void System_InstallIRQ_SimpleVbl();
10 extern void VSync();
11 extern void Stop();
12
13 // player.s
14 extern volatile unsigned char MusicPlaying;
15 extern volatile unsigned int MusicResetCounter;
16
17 extern unsigned int MusicLength;
18 extern void Mym_MusicStart();
19 extern void Mym_MusicStop();
20
21 // transitions.s
22 extern unsigned char PictureLoadBuffer[];
23 extern void PictureTransitionFromTopAndBottom();
24 extern void PictureTransitionVenicianStore();
25 extern void PictureTransitionUnroll();
26
27 extern void PictureDoTransition();
28
29 //extern void PrintDescription();
30
31
32 extern void InitTransitionData();
33
34 // scroller.s
35 extern unsigned char FontBuffer[];
36 extern void ScrollerInit();
37 extern void TestScroller();
38
39 // loader_api.s
40 extern unsigned char LoaderApiEntryIndex;
41 extern unsigned char LoaderApiAddressLow;
42 extern unsigned char LoaderApiAddressHigh;
43 extern void* LoaderApiAddress;
44
45 extern void SetLoadAddress();
46 extern void LoadFile();
47
48 void Pause(int delay)
49 {
50 int wasPlayingMusic=MusicPlaying;
51 int i;
52
53 for (i=0;i<delay;i++)
54 {
55 VSync();
56 if (MusicPlaying!=wasPlayingMusic)
57 {
58 break;
59 }
60 }
61 }
62
63 unsigned char CurrentMusic=0;
64 unsigned char CurrentPicture=0;
65 unsigned int PictureDelay=0;
66
67 void RetroIntro()
68 {
69 // Load and play the music
70 LoaderApiEntryIndex=LOADER_INTRO_MUSIC; // BeBop music
71 LoadFile();
72 /*
73 MusicLength=50*3; // 3 seconds
74 MusicLength=50*30; // 3 seconds
75 MusicLength=50*20; // 3 seconds
76 MusicLength=50*25; // 3 seconds
77 //MusicLength=50*28; // 3 seconds
78 MusicLength=50*24; // 3 seconds
79 */
80 Mym_MusicStart();
81
82 for (LoaderApiEntryIndex=LOADER_FIRST_INTRO_PICTURE;LoaderApiEntryIndex<LOADER_LAST_INTRO_PICTURE;LoaderApiEntryIndex++)
83 {
84 LoaderApiAddress=PictureLoadBuffer;
85 SetLoadAddress();
86 LoadFile();
87
88 PictureTransitionUnroll();
89
90 Pause(50*4);
91 }
92 //while (MusicPlaying);
93 //Mym_MusicStop();
94
95 // Clear the screen again
96 //memset((unsigned char*)0xa000,64,8000);
97 }
98
99
100 void main()
101 {
102 // Clear the screen
103 //memset((unsigned char*)0xa000,64,8000);
104 memset((unsigned char*)0x9900,0,0xbfe0-0x9900);
105
106 // Load the 6x8 font
107 LoaderApiEntryIndex=LOADER_FONT_6x8_ARTDECO;
108 LoadFile();
109
110 // Load the 12x16 font
111 LoaderApiEntryIndex=LOADER_FONT_12x16_ARTDECO; // 3040 bytes
112 LoaderApiAddress=FontBuffer;
113 SetLoadAddress();
114 LoadFile();
115
116 // Some basic inits
117 InitTransitionData();
118
119 // Install the IRQ handler
120 System_InstallIRQ_SimpleVbl();
121
122 // Play the black & white retro intro
123 RetroIntro();
124
125 // Start the scroller
126 ScrollerInit();
127
128 MusicPlaying=0;
129 while (1)
130 {
131 // Change the music if necessary
132 if (!MusicPlaying)
133 {
134 if ( (CurrentMusic<LOADER_FIRST_MUSIC) || (CurrentMusic>=LOADER_LAST_MUSIC) )
135 {
136 CurrentMusic=LOADER_FIRST_MUSIC;
137 }
138 LoaderApiEntryIndex=CurrentMusic++;
139 LoadFile();
140 Mym_MusicStop();
141 Mym_MusicStart();
142 }
143
144 if (MusicResetCounter>(200*2))
145 {
146 if (!PictureDelay)
147 {
148 // Next picture
149 if ( (CurrentPicture<LOADER_FIRST_PICTURE) || (CurrentPicture>=LOADER_LAST_PICTURE) )
150 {
151 CurrentPicture=LOADER_FIRST_PICTURE;
152 }
153 LoaderApiEntryIndex=CurrentPicture++;
154 LoaderApiAddress=PictureLoadBuffer;
155 SetLoadAddress();
156 LoadFile();
157
158 PictureDoTransition();
159
160 PictureDelay=50*5; // 5 seconds
161 }
162 else
163 {
164 PictureDelay--;
165 }
166 }
167 VSync();
168 }
169 }
170
171
172
173

  ViewVC Help
Powered by ViewVC 1.1.26