-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to gh-pages from @ 9937053 🚀
- Loading branch information
Showing
8 changed files
with
74 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,68 @@ | ||
/*****************************************************************************/ | ||
/* */ | ||
/* Atari VCS 2600 sample C program */ | ||
/* */ | ||
/* Florent Flament (contact@florentflament.com), 2017 */ | ||
/* */ | ||
/*****************************************************************************/ | ||
|
||
#include <atari2600.h> | ||
|
||
// PAL Timings | ||
// Roughly computed based on Stella Programmer's guide (Steve Wright) | ||
// scanlines count per section. | ||
#define VBLANK_TIM64 51 // 45 lines * 76 cycles/line / 64 cycles/tick | ||
#define KERNAL_T1024 17 // 228 lines * 76 cycles/line / 1024 cycles/tick | ||
#define OVERSCAN_TIM64 42 // 36 lines * 76 cycles/line / 64 cycles/tick | ||
|
||
// Testing memory zones | ||
const unsigned char rodata_v[] = "Hello!"; | ||
unsigned char data_v = 0x77; | ||
unsigned char bss_v; | ||
|
||
/* | ||
See the "VCSLib Demo" example for more features. | ||
*/ | ||
|
||
//#resource "vcslib/vcs-ca65.inc" | ||
//#resource "vcslib/kernel.inc" | ||
|
||
//#link "vcslib/vcslib.ca65" | ||
//#link "vcslib/frameloop.c" | ||
//#link "vcslib/mapper_3e.ca65" | ||
|
||
#include <peekpoke.h> | ||
#include "vcslib/bcd.h" | ||
#include "vcslib/vcslib.h" | ||
|
||
#pragma wrapped-call (push, bankselect, bank) | ||
#pragma code-name (push, "ROM0") | ||
|
||
void init(void) { | ||
// init code here | ||
} | ||
|
||
void my_preframe(void) { | ||
// stuff that happens before the frame is drawn | ||
TIA.colubk = 0x00; | ||
} | ||
|
||
void my_kernel(void) { | ||
byte i; | ||
for (i=0; i<190; i++) { | ||
do_wsync(); | ||
TIA.colubk = i; | ||
} | ||
} | ||
|
||
void my_postframe(void) { | ||
// stuff that happens after the frame is drawn | ||
} | ||
|
||
void kernel_loop() { | ||
while (1) { | ||
kernel_1(); | ||
my_preframe(); | ||
kernel_2(); | ||
my_kernel(); | ||
kernel_3(); | ||
my_postframe(); | ||
kernel_4(); | ||
} | ||
} | ||
|
||
#pragma code-name (pop) | ||
#pragma wrapped-call (pop) | ||
|
||
/* | ||
The main() function is called at startup. | ||
It resides in the shared ROM area (PERM). | ||
*/ | ||
void main(void) { | ||
unsigned char color = 0x79; // Stack variable | ||
bss_v = 0x88; // Testing BSS variable | ||
|
||
for/*ever*/(;;) { | ||
// Vertical Sync signal | ||
TIA.vsync = 0x02; | ||
TIA.wsync = 0x00; | ||
TIA.wsync = 0x00; | ||
TIA.wsync = 0x00; | ||
TIA.vsync = 0x00; | ||
|
||
// Vertical Blank timer setting | ||
RIOT.tim64t = VBLANK_TIM64; | ||
|
||
// Doing frame computation during blank | ||
TIA.colubk = color++; // Update color | ||
|
||
// Wait for end of Vertical Blank | ||
while (RIOT.timint == 0) {} | ||
TIA.wsync = 0x00; | ||
TIA.vblank = 0x00; // Turn on beam | ||
|
||
// Display frame | ||
RIOT.t1024t = KERNAL_T1024; | ||
while (RIOT.timint == 0) {} | ||
TIA.wsync = 0x00; | ||
TIA.vblank = 0x02; // Turn off beam | ||
|
||
// Overscan | ||
RIOT.tim64t = OVERSCAN_TIM64; | ||
while (RIOT.timint == 0) {} | ||
} | ||
|
||
// initialization | ||
init(); | ||
|
||
// main kernel loop | ||
kernel_loop(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters