initial commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// make space until 0x1000 by for the stack
|
||||
|
||||
#pragma stacksize(0x0600)
|
||||
|
||||
#pragma region( stack, 0x0a00, 0x1000, , , {stack} )
|
||||
|
||||
// everything beyond will be code, data, bss and heap to the end
|
||||
|
||||
#pragma region( main, 0x1000, 0xfff0, , , {code, data, bss, heap} )
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Install the IRQ trampoline
|
||||
|
||||
mmap_trampoline();
|
||||
|
||||
// Hide the basic ROM, must be first instruction
|
||||
|
||||
mmap_set(MMAP_RAM);
|
||||
|
||||
// Allocate all memory
|
||||
|
||||
unsigned total = 0;
|
||||
while (char * data = malloc(1024))
|
||||
{
|
||||
total += 1024;
|
||||
|
||||
// Swap in kernal for print
|
||||
|
||||
mmap_set(MMAP_NO_BASIC);
|
||||
printf("ALLOCATED %5u AT %04x\n", total, (unsigned)data);
|
||||
mmap_set(MMAP_RAM);
|
||||
|
||||
// Fill it with trash
|
||||
|
||||
for(unsigned i=0; i<1024; i++)
|
||||
data[i] = 0xaa;
|
||||
}
|
||||
|
||||
// Return basic ROM to normal state
|
||||
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
../../bin/oscar64 largemem.c
|
||||
../../bin/oscar64 allmem.c
|
||||
../../bin/oscar64 charsetlo.c
|
||||
../../bin/oscar64 charsethi.c
|
||||
../../bin/oscar64 charsetcopy.c
|
||||
../../bin/oscar64 charsetexpand.c
|
||||
../../bin/oscar64 charsetload.c -d64=charsetload.d64 -fz=../resources/charset.bin
|
||||
../../bin/oscar64 easyflash.c -n -tf=crt
|
||||
../../bin/oscar64 easyflashreloc.c -n -tf=crt
|
||||
../../bin/oscar64 easyflashshared.c -n -tf=crt
|
||||
../../bin/oscar64 easyflashcall.cpp -n -tf=crt
|
||||
../../bin/oscar64 tsr.c -n -dNOFLOAT -dNOLONG
|
||||
../../bin/oscar64 overlay.c -n -d64=overlay.d64
|
||||
@@ -0,0 +1,69 @@
|
||||
#include <c64/vic.h>
|
||||
#include <c64/memmap.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// make space until 0xcc00 by extending the default region
|
||||
|
||||
#pragma region( main, 0x0a00, 0xcc00, , , {code, data, bss, heap, stack} )
|
||||
|
||||
// space for our custom charset from c000 to c800, will be copied to
|
||||
// 0xd000 during startup to free space for stack and heap
|
||||
|
||||
#pragma section( charset, 0)
|
||||
|
||||
#pragma region( charset, 0xc000, 0xc800, , , {charset} )
|
||||
|
||||
// set initialized data segment to charset section
|
||||
|
||||
#pragma data(charset)
|
||||
|
||||
char charset[2048] = {
|
||||
#embed "../resources/charset.bin"
|
||||
};
|
||||
|
||||
// back to normal
|
||||
|
||||
#pragma data(data)
|
||||
|
||||
// pointers to charset and screen in memory
|
||||
|
||||
#define Screen ((char *)0xcc00)
|
||||
#define Charset ((char *)0xd000)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Install the trampoline
|
||||
mmap_trampoline();
|
||||
|
||||
// make all of RAM visible to the CPU
|
||||
mmap_set(MMAP_RAM);
|
||||
|
||||
// copy the font
|
||||
memcpy(Charset, charset, 2048);
|
||||
|
||||
// make lower part of RAM visible to CPU
|
||||
mmap_set(MMAP_NO_BASIC);
|
||||
|
||||
// map the vic to the new charset
|
||||
|
||||
vic_setmode(VICM_TEXT, Screen, Charset);
|
||||
|
||||
for(int i=0; i<1000; i++)
|
||||
Screen[i] = (char)i;
|
||||
|
||||
// wait for keypress
|
||||
|
||||
getchar();
|
||||
|
||||
// restore VIC
|
||||
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
|
||||
|
||||
// restore basic ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include <c64/vic.h>
|
||||
#include <c64/memmap.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <oscar.h>
|
||||
|
||||
// make space until 0xcc00 by extending the default region
|
||||
|
||||
#pragma region( main, 0x0a00, 0xcc00, , , {code, data, bss, heap, stack} )
|
||||
|
||||
// space for our custom charset from c000 to c800, will be copied to
|
||||
// 0xd000 during startup to free space for stack and heap
|
||||
|
||||
#pragma section( charset, 0)
|
||||
|
||||
#pragma region( charset, 0xc000, 0xc800, , , {charset} )
|
||||
|
||||
// set initialized data segment to charset section
|
||||
|
||||
#pragma data(charset)
|
||||
|
||||
// lz compressed data
|
||||
char charset[] = {
|
||||
#embed 2048 0 lzo "../resources/charset.bin"
|
||||
};
|
||||
|
||||
// back to normal
|
||||
|
||||
#pragma data(data)
|
||||
|
||||
// pointers to charset and screen in memory
|
||||
|
||||
#define Screen ((char *)0xcc00)
|
||||
#define Charset ((char *)0xd000)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Install the trampoline
|
||||
mmap_trampoline();
|
||||
|
||||
// make all of RAM visible to the CPU
|
||||
mmap_set(MMAP_RAM);
|
||||
|
||||
// expand the font
|
||||
oscar_expand_lzo(Charset, charset);
|
||||
|
||||
// make lower part of RAM visible to CPU
|
||||
mmap_set(MMAP_NO_BASIC);
|
||||
|
||||
// map the vic to the new charset
|
||||
|
||||
vic_setmode(VICM_TEXT, Screen, Charset);
|
||||
|
||||
for(int i=0; i<1000; i++)
|
||||
Screen[i] = (char)i;
|
||||
|
||||
// wait for keypress
|
||||
|
||||
getchar();
|
||||
|
||||
// restore VIC
|
||||
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
|
||||
|
||||
// restore basic ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <c64/vic.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// space for our custom charset from c800
|
||||
|
||||
#pragma section( charset, 0)
|
||||
|
||||
#pragma region( charset, 0xc800, 0xd000, , , {charset} )
|
||||
|
||||
#pragma data(charset)
|
||||
|
||||
char charset[2048] = {
|
||||
#embed "../resources/charset.bin"
|
||||
};
|
||||
|
||||
#pragma data(data)
|
||||
|
||||
#define Screen ((char *)0xc000)
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// map the vic to the new charset
|
||||
|
||||
vic_setmode(VICM_TEXT, Screen, charset);
|
||||
|
||||
for(int i=0; i<1000; i++)
|
||||
Screen[i] = (char)i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#include <c64/vic.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// make space until 0x2000 for code and data
|
||||
|
||||
#pragma region( lower, 0x0a00, 0x2000, , , {code, data} )
|
||||
|
||||
// then space for our custom charset
|
||||
|
||||
#pragma section( charset, 0)
|
||||
|
||||
#pragma region( charset, 0x2000, 0x2800, , , {charset} )
|
||||
|
||||
// everything beyond will be code, data, bss and heap to the end
|
||||
|
||||
#pragma region( main, 0x2800, 0xa000, , , {code, data, bss, heap, stack} )
|
||||
|
||||
|
||||
#pragma data(charset)
|
||||
|
||||
char charset[2048] = {
|
||||
#embed "../resources/charset.bin"
|
||||
};
|
||||
|
||||
#pragma data(data)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// map the vic to the new charset
|
||||
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, charset);
|
||||
|
||||
for(int i=0; i<10; i++)
|
||||
printf(p"%D Hello World\n", i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <c64/vic.h>
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/kernalio.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define Screen ((char *)0xcc00)
|
||||
#define Charset ((char *)0xc000)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Set name for file and open it on drive 9
|
||||
krnio_setnam("CHARSET,P,R");
|
||||
if (krnio_open(2, 8, 2))
|
||||
{
|
||||
// Read the content of the file into the charset buffer,
|
||||
// decompressing on the fly
|
||||
krnio_read_lzo(2, Charset);
|
||||
|
||||
// Close the file
|
||||
krnio_close(2);
|
||||
}
|
||||
|
||||
// Change display address to new screen and charset
|
||||
|
||||
vic_setmode(VICM_TEXT, Screen, Charset);
|
||||
|
||||
for(int i=0; i<1000; i++)
|
||||
Screen[i] = (char)i;
|
||||
|
||||
// wait for keypress
|
||||
|
||||
getchar();
|
||||
|
||||
// restore VIC
|
||||
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
|
||||
|
||||
// restore basic ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/charwin.h>
|
||||
#include <c64/cia.h>
|
||||
#include <c64/vic.h>
|
||||
#include <c64/easyflash.h>
|
||||
|
||||
// Shared code/data region, copied from easyflash bank 0 to ram during startup
|
||||
|
||||
#pragma region( main, 0x0900, 0x8000, , , { code, data, bss, heap, stack } )
|
||||
|
||||
// Section and region for first easyflash bank
|
||||
|
||||
#pragma section( bcode1, 0 )
|
||||
#pragma section( bdata1, 0 )
|
||||
#pragma region(bank1, 0x8000, 0xc000, , 1, { bcode1, bdata1 } )
|
||||
|
||||
// Section and region for second easyflash bank
|
||||
|
||||
#pragma section( bcode2, 0 )
|
||||
#pragma section( bdata2, 0 )
|
||||
#pragma region(bank2, 0x8000, 0xc000, , 2, { bcode2, bdata2 } )
|
||||
|
||||
#pragma section( bcode3, 0 )
|
||||
#pragma section( bdata3, 0 )
|
||||
#pragma region(bank3, 0x8000, 0xc000, , 3, { bcode3, bdata3 } )
|
||||
|
||||
#pragma section( bcode4, 0 )
|
||||
#pragma section( bdata4, 0 )
|
||||
#pragma region(bank4, 0x8000, 0xc000, , 4, { bcode4, bdata4 } )
|
||||
|
||||
#pragma section( bcode5, 0 )
|
||||
#pragma section( bdata5, 0 )
|
||||
#pragma region(bank5, 0x8000, 0xc000, , 5, { bcode5, bdata5 } )
|
||||
|
||||
#pragma section( bcode6, 0 )
|
||||
#pragma section( bdata6, 0 )
|
||||
#pragma region(bank6, 0x8000, 0xc000, , 6, { bcode6, bdata6 } )
|
||||
|
||||
// Charwin in shared memory section
|
||||
|
||||
CharWin cw;
|
||||
|
||||
// Now switch code generation to bank 1
|
||||
|
||||
#pragma code ( bcode1 )
|
||||
#pragma data ( bdata1 )
|
||||
|
||||
// Print into shared charwin
|
||||
|
||||
void print1(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is first bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Now switch code generation to bank 2
|
||||
|
||||
#pragma code ( bcode2 )
|
||||
#pragma data ( bdata2 )
|
||||
|
||||
void print2(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is second bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode3 )
|
||||
#pragma data ( bdata3 )
|
||||
|
||||
void print3(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is third bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode4 )
|
||||
#pragma data ( bdata4 )
|
||||
|
||||
void print4(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fourth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode5 )
|
||||
#pragma data ( bdata5 )
|
||||
|
||||
void print5(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fifth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode6 )
|
||||
#pragma data ( bdata6 )
|
||||
|
||||
void print6(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is sixth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Switching code generation back to shared section
|
||||
|
||||
#pragma code ( code )
|
||||
#pragma data ( data )
|
||||
|
||||
|
||||
// Function for indirect cross bank call
|
||||
void fcall(char bank, void (* func)())
|
||||
{
|
||||
eflash.bank = bank;
|
||||
func();
|
||||
}
|
||||
|
||||
// Macro for indirect cross bank call
|
||||
#define FCALL(f) fcall(__bankof(f), f)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Enable ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
// Init CIAs (no kernal rom was executed so far)
|
||||
cia_init();
|
||||
|
||||
// Init VIC
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1800);
|
||||
|
||||
// Prepare output window
|
||||
cwin_init(&cw, (char *)0x0400, 0, 0, 40, 25);
|
||||
cwin_clear(&cw);
|
||||
|
||||
// Switch easyflash ROM region to bank 1
|
||||
eflash.bank = 1;
|
||||
|
||||
// Call function in bank 1
|
||||
print1();
|
||||
|
||||
// Switch easyflash ROM region to bank 2
|
||||
eflash.bank = 2;
|
||||
|
||||
// Call function in bank 2
|
||||
print2();
|
||||
|
||||
eflash.bank = 3;
|
||||
print3();
|
||||
|
||||
// Get bank of function using __bankof operator
|
||||
eflash.bank = __bankof print4;
|
||||
print4();
|
||||
|
||||
// Indirect call
|
||||
fcall(__bankof print5, print5);
|
||||
|
||||
// Macro call
|
||||
FCALL(print6);
|
||||
|
||||
// Loop forever
|
||||
while (true)
|
||||
;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/charwin.h>
|
||||
#include <c64/cia.h>
|
||||
#include <c64/vic.h>
|
||||
#include <c64/easyflash.h>
|
||||
|
||||
// Shared code/data region, copied from easyflash bank 0 to ram during startup
|
||||
|
||||
#pragma region( main, 0x0900, 0x8000, , , { code, data, bss, heap, stack } )
|
||||
|
||||
// Section and region for first easyflash bank
|
||||
|
||||
#pragma section( bcode1, 0 )
|
||||
#pragma section( bdata1, 0 )
|
||||
#pragma region(bank1, 0x8000, 0xc000, , 1, { bcode1, bdata1 } )
|
||||
|
||||
// Section and region for second easyflash bank
|
||||
|
||||
#pragma section( bcode2, 0 )
|
||||
#pragma section( bdata2, 0 )
|
||||
#pragma region(bank2, 0x8000, 0xc000, , 2, { bcode2, bdata2 } )
|
||||
|
||||
#pragma section( bcode3, 0 )
|
||||
#pragma section( bdata3, 0 )
|
||||
#pragma region(bank3, 0x8000, 0xc000, , 3, { bcode3, bdata3 } )
|
||||
|
||||
#pragma section( bcode4, 0 )
|
||||
#pragma section( bdata4, 0 )
|
||||
#pragma region(bank4, 0x8000, 0xc000, , 4, { bcode4, bdata4 } )
|
||||
|
||||
#pragma section( bcode5, 0 )
|
||||
#pragma section( bdata5, 0 )
|
||||
#pragma region(bank5, 0x8000, 0xc000, , 5, { bcode5, bdata5 } )
|
||||
|
||||
#pragma section( bcode6, 0 )
|
||||
#pragma section( bdata6, 0 )
|
||||
#pragma region(bank6, 0x8000, 0xc000, , 6, { bcode6, bdata6 } )
|
||||
|
||||
// Charwin in shared memory section
|
||||
|
||||
CharWin cw;
|
||||
|
||||
// Now switch code generation to bank 1
|
||||
|
||||
#pragma code ( bcode1 )
|
||||
#pragma data ( bdata1 )
|
||||
|
||||
// Print into shared charwin
|
||||
|
||||
void print1_p(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is first bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Now switch code generation to bank 2
|
||||
|
||||
#pragma code ( bcode2 )
|
||||
#pragma data ( bdata2 )
|
||||
|
||||
void print2_p(const char * p)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is second bank:", 7);
|
||||
cwin_put_string(&cw, p, 1);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode3 )
|
||||
#pragma data ( bdata3 )
|
||||
|
||||
void print3_p(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is third bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode4 )
|
||||
#pragma data ( bdata4 )
|
||||
|
||||
void print4_p(int x, int y)
|
||||
{
|
||||
cwin_cursor_move(&cw, x, y);
|
||||
cwin_put_string(&cw, p"This is fourth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode5 )
|
||||
#pragma data ( bdata5 )
|
||||
|
||||
void print5_p(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fifth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
void print5a_p(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fifth bank second", 14);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Switching code generation back to shared section
|
||||
|
||||
#pragma code ( code )
|
||||
#pragma data ( data )
|
||||
|
||||
|
||||
EF_CALL(print1);
|
||||
EF_CALL(print2);
|
||||
EF_CALL(print3);
|
||||
EF_CALL(print4);
|
||||
EF_CALL(print5);
|
||||
EF_CALL(print5a);
|
||||
|
||||
#pragma code ( bcode6 )
|
||||
#pragma data ( bdata6 )
|
||||
|
||||
void print6_p(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is sixth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
print5a();
|
||||
cwin_put_string(&cw, p"This is sixth bank again", 7);
|
||||
}
|
||||
|
||||
#pragma code ( code )
|
||||
#pragma data ( data )
|
||||
|
||||
EF_CALL(print6);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Enable ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
// Init CIAs (no kernal rom was executed so far)
|
||||
cia_init();
|
||||
|
||||
// Init VIC
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1800);
|
||||
|
||||
// Prepare output window
|
||||
cwin_init(&cw, (char *)0x0400, 0, 0, 40, 25);
|
||||
cwin_clear(&cw);
|
||||
|
||||
print1();
|
||||
print2("hello");
|
||||
print3();
|
||||
print4(5, 8);
|
||||
print5();
|
||||
print6();
|
||||
|
||||
// Loop forever
|
||||
while (true)
|
||||
;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/charwin.h>
|
||||
#include <c64/cia.h>
|
||||
#include <c64/vic.h>
|
||||
#include <string.h>
|
||||
|
||||
#pragma section( startup, 0 )
|
||||
|
||||
#pragma region( startup, 0x0100, 0x0200, , , { startup } )
|
||||
|
||||
#pragma region( main, 0x0400, 0x8000, , , { code, data, bss, heap, stack } )
|
||||
|
||||
CharWin cw;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Copy Char ROM
|
||||
mmap_set(MMAP_ALL_ROM);
|
||||
|
||||
memcpy((char *)0xd000, (char *)0xd000, 0x1000);
|
||||
|
||||
// Enable ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
// Init CIAs (no kernal rom was executed so far)
|
||||
cia_init();
|
||||
|
||||
// Init VIC
|
||||
vic_setmode(VICM_TEXT, (char *)0xc000, (char *)0xd800);
|
||||
|
||||
// Prepare output window
|
||||
cwin_init(&cw, (char *)0xc000, 0, 0, 40, 25);
|
||||
cwin_clear(&cw);
|
||||
|
||||
cwin_put_string(&cw, p"Hello World", 7);
|
||||
|
||||
while (true) ;
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/charwin.h>
|
||||
#include <c64/cia.h>
|
||||
#include <c64/vic.h>
|
||||
#include <c64/easyflash.h>
|
||||
#include <string.h>
|
||||
|
||||
// Shared code/data region, copied from easyflash bank 0 to ram during startup
|
||||
|
||||
#pragma region( main, 0x0900, 0x8000, , , { code, data, bss, heap, stack } )
|
||||
|
||||
// Section and region for first easyflash bank, code is compiled for a
|
||||
// target address of 0x7000 but placed into the bank at 0x8000
|
||||
// The data section is first to ensure the jump table is at the start
|
||||
// address
|
||||
|
||||
#pragma section( bcode1, 0 )
|
||||
#pragma section( bdata1, 0 )
|
||||
#pragma region(bank1, 0x8000, 0x9000, , 1, { bdata1, bcode1 }, 0x7000 )
|
||||
|
||||
// Section and region for second easyflash bank
|
||||
|
||||
#pragma section( bcode2, 0 )
|
||||
#pragma section( bdata2, 0 )
|
||||
#pragma region(bank2, 0x8000, 0x9000, , 2, { bdata2, bcode2 }, 0x7000 )
|
||||
|
||||
#pragma section( bcode3, 0 )
|
||||
#pragma section( bdata3, 0 )
|
||||
#pragma region(bank3, 0x8000, 0x9000, , 3, { bdata3, bcode3 }, 0x7000 )
|
||||
|
||||
#pragma section( bcode4, 0 )
|
||||
#pragma section( bdata4, 0 )
|
||||
#pragma region(bank4, 0x8000, 0x9000, , 4, { bdata4, bcode4 }, 0x7000 )
|
||||
|
||||
#pragma section( bcode5, 0 )
|
||||
#pragma section( bdata5, 0 )
|
||||
#pragma region(bank5, 0x8000, 0x9000, , 5, { bdata5, bcode5 }, 0x7000 )
|
||||
|
||||
#pragma section( bcode6, 0 )
|
||||
#pragma section( bdata6, 0 )
|
||||
#pragma region(bank6, 0x8000, 0x9000, , 6, { bdata6, bcode6 } , 0x7000 )
|
||||
|
||||
// Charwin in shared memory section
|
||||
|
||||
CharWin cw;
|
||||
|
||||
struct EntryTable
|
||||
{
|
||||
void (*fhello)(void);
|
||||
void (*fdone)(void);
|
||||
};
|
||||
|
||||
// Now switch code generation to bank 1
|
||||
|
||||
#pragma code ( bcode1 )
|
||||
#pragma data ( bdata1 )
|
||||
|
||||
// Print into shared charwin
|
||||
|
||||
void print1(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is first bank", 7);
|
||||
}
|
||||
|
||||
void done1(void)
|
||||
{
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
const EntryTable entry1 = {
|
||||
.fhello = &print1,
|
||||
.fdone = &done1
|
||||
};
|
||||
|
||||
// make sure the function is referenced
|
||||
#pragma reference(entry1)
|
||||
|
||||
// Now switch code generation to bank 2
|
||||
|
||||
#pragma code ( bcode2 )
|
||||
#pragma data ( bdata2 )
|
||||
|
||||
void print2(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is second bank", 7);
|
||||
}
|
||||
|
||||
void done2(void)
|
||||
{
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
const EntryTable entry2 = {
|
||||
.fhello = &print2,
|
||||
.fdone = &done2
|
||||
};
|
||||
|
||||
// make sure the function is referenced
|
||||
#pragma reference(entry2)
|
||||
|
||||
#pragma code ( bcode3 )
|
||||
#pragma data ( bdata3 )
|
||||
|
||||
void print3(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is third bank", 7);
|
||||
}
|
||||
|
||||
void done3(void)
|
||||
{
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
const EntryTable entry3 = {
|
||||
.fhello = &print3,
|
||||
.fdone = &done3
|
||||
};
|
||||
|
||||
#pragma reference(entry3)
|
||||
|
||||
#pragma code ( bcode4 )
|
||||
#pragma data ( bdata4 )
|
||||
|
||||
void print4(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fourth bank", 7);
|
||||
}
|
||||
|
||||
void done4(void)
|
||||
{
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
const EntryTable entry4 = {
|
||||
.fhello = &print4,
|
||||
.fdone = &done4
|
||||
};
|
||||
|
||||
#pragma reference(entry4)
|
||||
|
||||
#pragma code ( bcode5 )
|
||||
#pragma data ( bdata5 )
|
||||
|
||||
void print5(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fifth bank", 7);
|
||||
}
|
||||
|
||||
void done5(void)
|
||||
{
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
const EntryTable entry5 = {
|
||||
.fhello = &print5,
|
||||
.fdone = &done5
|
||||
};
|
||||
|
||||
#pragma reference(entry5)
|
||||
|
||||
#pragma code ( bcode6 )
|
||||
#pragma data ( bdata6 )
|
||||
|
||||
void print6(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is sixth bank", 7);
|
||||
}
|
||||
|
||||
void done6(void)
|
||||
{
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
const EntryTable entry6 = {
|
||||
.fhello = &print6,
|
||||
.fdone = &done6
|
||||
};
|
||||
|
||||
#pragma reference(entry6)
|
||||
|
||||
// Switching code generation back to shared section
|
||||
|
||||
#pragma code ( code )
|
||||
#pragma data ( data )
|
||||
|
||||
// Copy the data of the rom bank, and call the function
|
||||
// with the jump table
|
||||
|
||||
void callbank(char bank)
|
||||
{
|
||||
eflash.bank = bank;
|
||||
memcpy((char *)0x7000, (char *)0x8000, 0x1000);
|
||||
|
||||
// call function at start of copied section
|
||||
((EntryTable *)0x7000)->fhello();
|
||||
((EntryTable *)0x7000)->fdone();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Enable ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
// Init CIAs (no kernal rom was executed so far)
|
||||
cia_init();
|
||||
|
||||
// Init VIC
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1800);
|
||||
|
||||
// Prepare output window
|
||||
cwin_init(&cw, (char *)0x0400, 0, 0, 40, 25);
|
||||
cwin_clear(&cw);
|
||||
|
||||
|
||||
// Call function in bank 1
|
||||
callbank(1);
|
||||
|
||||
// Switch easyflash ROM region to bank 2
|
||||
callbank(2);
|
||||
|
||||
callbank(3);
|
||||
callbank(4);
|
||||
callbank(5);
|
||||
callbank(6);
|
||||
|
||||
// Loop forever
|
||||
while (true)
|
||||
;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/charwin.h>
|
||||
#include <c64/cia.h>
|
||||
#include <c64/vic.h>
|
||||
#include <c64/easyflash.h>
|
||||
|
||||
// Shared code/data region, copied from easyflash bank 0 to ram during startup
|
||||
|
||||
#pragma region( main, 0x0900, 0x8000, , , { code, data, bss, heap, stack } )
|
||||
|
||||
|
||||
#pragma section( bcode1, 0 )
|
||||
#pragma section( bdata1, 0 )
|
||||
#pragma region(bank1, 0x8000, 0xbf00, , 1, { bcode1, bdata1 } )
|
||||
|
||||
// Section and region for second easyflash bank
|
||||
|
||||
#pragma section( bcode2, 0 )
|
||||
#pragma section( bdata2, 0 )
|
||||
#pragma region(bank2, 0x8000, 0xbf00, , 2, { bcode2, bdata2 } )
|
||||
|
||||
#pragma section( bcode3, 0 )
|
||||
#pragma section( bdata3, 0 )
|
||||
#pragma region(bank3, 0x8000, 0xbf00, , 3, { bcode3, bdata3 } )
|
||||
|
||||
#pragma section( bcode4, 0 )
|
||||
#pragma section( bdata4, 0 )
|
||||
#pragma region(bank4, 0x8000, 0xbf00, , 4, { bcode4, bdata4 } )
|
||||
|
||||
#pragma section( bcode5, 0 )
|
||||
#pragma section( bdata5, 0 )
|
||||
#pragma region(bank5, 0x8000, 0xbf00, , 5, { bcode5, bdata5 } )
|
||||
|
||||
#pragma section( bcode6, 0 )
|
||||
#pragma section( bdata6, 0 )
|
||||
#pragma region(bank6, 0x8000, 0xbf00, , 6, { bcode6, bdata6 } )
|
||||
|
||||
// Charwin in shared memory section
|
||||
|
||||
CharWin cw;
|
||||
|
||||
// Setting up a common range
|
||||
|
||||
#pragma section( ccode, 0 )
|
||||
#pragma region( cbank, 0xbf00, 0xc000, , {1, 2, 3, 4, 5, 6}, { ccode } )
|
||||
|
||||
// Code shared by all banks
|
||||
|
||||
#pragma code( ccode )
|
||||
|
||||
__export void callbank(void (* fn)(void), char bank)
|
||||
{
|
||||
eflash.bank = bank;
|
||||
fn();
|
||||
}
|
||||
|
||||
#pragma code( code )
|
||||
|
||||
// Now switch code generation to bank 1
|
||||
|
||||
#pragma code ( bcode1 )
|
||||
#pragma data ( bdata1 )
|
||||
|
||||
// Print into shared charwin
|
||||
|
||||
void print1(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is first bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Now switch code generation to bank 2
|
||||
|
||||
#pragma code ( bcode2 )
|
||||
#pragma data ( bdata2 )
|
||||
|
||||
void print2(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is second bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode3 )
|
||||
#pragma data ( bdata3 )
|
||||
|
||||
void print3(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is third bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode4 )
|
||||
#pragma data ( bdata4 )
|
||||
|
||||
void print4(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fourth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode5 )
|
||||
#pragma data ( bdata5 )
|
||||
|
||||
void print5(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fifth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode6 )
|
||||
#pragma data ( bdata6 )
|
||||
|
||||
void print6(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is sixth bank", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Switching code generation back to shared section
|
||||
|
||||
#pragma code ( code )
|
||||
#pragma data ( data )
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Enable ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
// Init CIAs (no kernal rom was executed so far)
|
||||
cia_init();
|
||||
|
||||
// Init VIC
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1800);
|
||||
|
||||
// Prepare output window
|
||||
cwin_init(&cw, (char *)0x0400, 0, 0, 40, 25);
|
||||
cwin_clear(&cw);
|
||||
|
||||
eflash.bank = 1;
|
||||
|
||||
// Call function in bank 1
|
||||
callbank(print1, 1);
|
||||
|
||||
// Call function in bank 2
|
||||
callbank(print2, 2);
|
||||
|
||||
callbank(print3, 3);
|
||||
callbank(print4, 4);
|
||||
callbank(print5, 5);
|
||||
callbank(print6, 6);
|
||||
|
||||
// Loop forever
|
||||
while (true)
|
||||
;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// make space until 0xd000 by extending the default region
|
||||
|
||||
#pragma region( main, 0x0a00, 0xd000, , , {code, data, bss, heap, stack} )
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Hide the basic ROM, must be first instruction
|
||||
|
||||
mmap_set(MMAP_NO_BASIC);
|
||||
|
||||
// Allocate all memory
|
||||
|
||||
unsigned total = 0;
|
||||
while (char * data = malloc(1024))
|
||||
{
|
||||
total += 1024;
|
||||
|
||||
printf("ALLOCATED %5u AT %04x\n", total, (unsigned)data);
|
||||
|
||||
// Fill it with trash
|
||||
|
||||
for(unsigned i=0; i<1024; i++)
|
||||
data[i] = 0xaa;
|
||||
}
|
||||
|
||||
// Return basic ROM to normal state
|
||||
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/charwin.h>
|
||||
#include <c64/cia.h>
|
||||
#include <c64/vic.h>
|
||||
|
||||
// Set rom region end at 0x9f80 to leave some space for copy code
|
||||
#pragma region(rom, 0x8080, 0x9f80, , 0, { code, data } )
|
||||
|
||||
// We do not want to pollute main RAM region with our data
|
||||
#pragma region(main, 0xc000, 0xd000, , , { bss, stack, heap })
|
||||
#pragma stacksize( 256 )
|
||||
|
||||
// Region and code for a cross bank copy routine
|
||||
#pragma section( ccode, 0 )
|
||||
#pragma region( crom, 0x9f80, 0xa000, , 0, { ccode }, 0x0380 )
|
||||
|
||||
CharWin cw;
|
||||
|
||||
// Copy code from any bank to RAM, returns to bank 0, this code is
|
||||
// copied from bank 0 to RAM at 0x0380 at program start
|
||||
|
||||
#pragma code ( ccode )
|
||||
|
||||
__export void ccopy(char bank, char * dst, const char * src, unsigned n)
|
||||
{
|
||||
*((volatile char *)0xde00) = bank;
|
||||
while (n)
|
||||
{
|
||||
*dst++ = *src++;
|
||||
n--;
|
||||
}
|
||||
*((volatile char *)0xde00) = 0;
|
||||
}
|
||||
|
||||
// Region of code to be executed from RAM after copied from 2nd ROM
|
||||
// bank
|
||||
|
||||
#pragma section( bcode1, 0 )
|
||||
#pragma section( bdata1, 0 )
|
||||
#pragma region(bank1, 0x8000, 0xa000, , 1, { bcode1, bdata1 }, 0x2000 )
|
||||
|
||||
#pragma code ( bcode1 )
|
||||
#pragma data ( bdata1 )
|
||||
|
||||
// Print into shared charwin
|
||||
|
||||
void print1(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is first bank", 1);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Back to main sections in bank 0
|
||||
|
||||
#pragma code ( code )
|
||||
#pragma data ( data )
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Enable ROM
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
// Init CIAs (no kernal rom was executed so far)
|
||||
cia_init();
|
||||
|
||||
// Copy ccopy code to RAM
|
||||
for(char i=0; i<128; i++)
|
||||
((char *)0x0380)[i] = ((char *)0x9f80)[i];
|
||||
|
||||
// Init VIC
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1800);
|
||||
|
||||
// Prepare output window
|
||||
cwin_init(&cw, (char *)0x0400, 0, 0, 40, 25);
|
||||
cwin_clear(&cw);
|
||||
|
||||
// Write first line
|
||||
cwin_put_string(&cw, p"Hello World", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
|
||||
// Copy bank 1 to RAM
|
||||
ccopy(1, (char *)0x2000, (char *)0x8000, 0x2000);
|
||||
|
||||
// Call function in copy
|
||||
print1();
|
||||
|
||||
// Third line
|
||||
cwin_put_string(&cw, p"Final words", 14);
|
||||
cwin_cursor_newline(&cw);
|
||||
|
||||
while (true) ;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
call ..\..\bin\oscar64 largemem.c
|
||||
call ..\..\bin\oscar64 allmem.c
|
||||
call ..\..\bin\oscar64 charsetlo.c
|
||||
call ..\..\bin\oscar64 charsethi.c
|
||||
call ..\..\bin\oscar64 charsetcopy.c
|
||||
call ..\..\bin\oscar64 charsetexpand.c
|
||||
call ..\..\bin\oscar64 charsetload.c -d64=charsetload.d64 -fz=../resources/charset.bin
|
||||
call ..\..\bin\oscar64 easyflash.c -n -tf=crt
|
||||
call ..\..\bin\oscar64 easyflashreloc.c -n -tf=crt
|
||||
call ..\..\bin\oscar64 easyflashshared.c -n -tf=crt
|
||||
call ..\..\bin\oscar64 easyflashlow.c -n -tf=crt
|
||||
call ..\..\bin\oscar64 easyflashcall.cpp -n -tf=crt
|
||||
call ..\..\bin\oscar64 tsr.c -n -dNOFLOAT -dNOLONG
|
||||
call ..\..\bin\oscar64 overlay.c -n -d64=overlay.d64
|
||||
call ..\..\bin\oscar64 overlaylzo.c -n -d64=overlaylzo.d64
|
||||
call ..\..\bin\oscar64 magicdesk.c -n -tf=crt8 -cid=19
|
||||
@@ -0,0 +1,30 @@
|
||||
%.prg: %.c
|
||||
@echo "Compiling sample file" $<
|
||||
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $<
|
||||
|
||||
all: largemem.prg allmem.prg charsetlo.prg charsethi.prg charsetcopy.prg charsetexpand.prg \
|
||||
charsetload.prg easyflash.crt easyflashreloc.crt easyflashshared.crt tsr.prg overlay.prg
|
||||
|
||||
charsetload.prg: charsetload.c ../resources/charset.bin
|
||||
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -d64=charsetload.d64 -fz=../resources/charset.bin
|
||||
|
||||
easyflash.crt: easyflash.c
|
||||
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -tf=crt
|
||||
|
||||
easyflashreloc.crt: easyflashreloc.c
|
||||
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -tf=crt
|
||||
|
||||
easyflashshared.crt: easyflashshared.c
|
||||
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -tf=crt
|
||||
|
||||
tsr.prg: tsr.c
|
||||
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -dNOFLOAT -dNOLONG
|
||||
|
||||
overlay.prg: overlay.c
|
||||
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -d64=overlay.d64
|
||||
|
||||
overlay.prg: overlaylzo.c
|
||||
@$(OSCAR64_CC) $(OSCAR64_CFLAGS) $< -n -d64=overlaylzo.d64
|
||||
|
||||
clean:
|
||||
@$(RM) *.asm *.int *.lbl *.map *.prg *.bcs *.d64 *.crt
|
||||
@@ -0,0 +1,157 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/charwin.h>
|
||||
#include <c64/cia.h>
|
||||
#include <c64/vic.h>
|
||||
#include <c64/kernalio.h>
|
||||
|
||||
// Common memory area for all overlays
|
||||
|
||||
#pragma region( main, 0x0900, 0x8000, , , { code, data, bss, heap, stack } )
|
||||
|
||||
// Section and region for first overlay bank
|
||||
|
||||
#pragma overlay( ovl1, 1 )
|
||||
#pragma section( bcode1, 0 )
|
||||
#pragma section( bdata1, 0 )
|
||||
#pragma region(bank1, 0x8000, 0xc000, , 1, { bcode1, bdata1 } )
|
||||
|
||||
// Section and region for second overlay bank
|
||||
|
||||
#pragma overlay( ovl2, 2 )
|
||||
#pragma section( bcode2, 0 )
|
||||
#pragma section( bdata2, 0 )
|
||||
#pragma region(bank2, 0x8000, 0xc000, , 2, { bcode2, bdata2 } )
|
||||
|
||||
#pragma overlay( ovl3, 3 )
|
||||
#pragma section( bcode3, 0 )
|
||||
#pragma section( bdata3, 0 )
|
||||
#pragma region(bank3, 0x8000, 0xc000, , 3, { bcode3, bdata3 } )
|
||||
|
||||
#pragma overlay( ovl4, 4 )
|
||||
#pragma section( bcode4, 0 )
|
||||
#pragma section( bdata4, 0 )
|
||||
#pragma region(bank4, 0x8000, 0xc000, , 4, { bcode4, bdata4 } )
|
||||
|
||||
#pragma overlay( ovl5, 5 )
|
||||
#pragma section( bcode5, 0 )
|
||||
#pragma section( bdata5, 0 )
|
||||
#pragma region(bank5, 0x8000, 0xc000, , 5, { bcode5, bdata5 } )
|
||||
|
||||
#pragma overlay( ovl6, 6 )
|
||||
#pragma section( bcode6, 0 )
|
||||
#pragma section( bdata6, 0 )
|
||||
#pragma region(bank6, 0x8000, 0xc000, , 6, { bcode6, bdata6 } )
|
||||
|
||||
// Charwin in shared memory section
|
||||
|
||||
CharWin cw;
|
||||
|
||||
// Now switch code generation to bank 1
|
||||
|
||||
#pragma code ( bcode1 )
|
||||
#pragma data ( bdata1 )
|
||||
|
||||
// Print into shared charwin
|
||||
|
||||
void print1(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is first overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Now switch code generation to bank 2
|
||||
|
||||
#pragma code ( bcode2 )
|
||||
#pragma data ( bdata2 )
|
||||
|
||||
void print2(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is second overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode3 )
|
||||
#pragma data ( bdata3 )
|
||||
|
||||
void print3(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is third overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode4 )
|
||||
#pragma data ( bdata4 )
|
||||
|
||||
void print4(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fourth overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode5 )
|
||||
#pragma data ( bdata5 )
|
||||
|
||||
void print5(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fifth overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode6 )
|
||||
#pragma data ( bdata6 )
|
||||
|
||||
void print6(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is sixth overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Switching code generation back to shared section
|
||||
|
||||
#pragma code ( code )
|
||||
#pragma data ( data )
|
||||
|
||||
// Load an overlay section into memory
|
||||
|
||||
void load(const char * fname)
|
||||
{
|
||||
krnio_setnam(fname);
|
||||
krnio_load(1, 8, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Kernal memory only
|
||||
mmap_set(MMAP_NO_BASIC);
|
||||
|
||||
// Init VIC
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1800);
|
||||
|
||||
// Prepare output window
|
||||
cwin_init(&cw, (char *)0x0400, 0, 0, 40, 25);
|
||||
cwin_clear(&cw);
|
||||
|
||||
// Call function in overlay 1
|
||||
load(P"OVL1");
|
||||
print1();
|
||||
|
||||
// Call function in overlay 2
|
||||
load(P"OVL2");
|
||||
print2();
|
||||
|
||||
load(P"OVL3");
|
||||
print3();
|
||||
|
||||
load(P"OVL4");
|
||||
print4();
|
||||
|
||||
load(P"OVL5");
|
||||
print5();
|
||||
|
||||
load(P"OVL6");
|
||||
print6();
|
||||
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
#include <c64/memmap.h>
|
||||
#include <c64/charwin.h>
|
||||
#include <c64/cia.h>
|
||||
#include <c64/vic.h>
|
||||
#include <c64/kernalio.h>
|
||||
#include <oscar.h>
|
||||
|
||||
// Common memory area for all overlays
|
||||
|
||||
#pragma region( main, 0x0900, 0x8000, , , { code, data, bss, heap, stack } )
|
||||
|
||||
// Section and region for first overlay bank
|
||||
|
||||
#pragma overlay( ovl1, 1, lzo )
|
||||
#pragma section( bcode1, 0 )
|
||||
#pragma section( bdata1, 0 )
|
||||
#pragma region(bank1, 0x8000, 0xc000, , 1, { bcode1, bdata1 } )
|
||||
|
||||
// Section and region for second overlay bank
|
||||
|
||||
#pragma overlay( ovl2, 2, lzo )
|
||||
#pragma section( bcode2, 0 )
|
||||
#pragma section( bdata2, 0 )
|
||||
#pragma region(bank2, 0x8000, 0xc000, , 2, { bcode2, bdata2 } )
|
||||
|
||||
#pragma overlay( ovl3, 3, lzo )
|
||||
#pragma section( bcode3, 0 )
|
||||
#pragma section( bdata3, 0 )
|
||||
#pragma region(bank3, 0x8000, 0xc000, , 3, { bcode3, bdata3 } )
|
||||
|
||||
#pragma overlay( ovl4, 4, lzo )
|
||||
#pragma section( bcode4, 0 )
|
||||
#pragma section( bdata4, 0 )
|
||||
#pragma region(bank4, 0x8000, 0xc000, , 4, { bcode4, bdata4 } )
|
||||
|
||||
#pragma overlay( ovl5, 5, lzo )
|
||||
#pragma section( bcode5, 0 )
|
||||
#pragma section( bdata5, 0 )
|
||||
#pragma region(bank5, 0x8000, 0xc000, , 5, { bcode5, bdata5 } )
|
||||
|
||||
#pragma overlay( ovl6, 6, lzo )
|
||||
#pragma section( bcode6, 0 )
|
||||
#pragma section( bdata6, 0 )
|
||||
#pragma region(bank6, 0x8000, 0xc000, , 6, { bcode6, bdata6 } )
|
||||
|
||||
// Charwin in shared memory section
|
||||
|
||||
CharWin cw;
|
||||
|
||||
// Now switch code generation to bank 1
|
||||
|
||||
#pragma code ( bcode1 )
|
||||
#pragma data ( bdata1 )
|
||||
|
||||
// Print into shared charwin
|
||||
|
||||
void print1(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is first overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Now switch code generation to bank 2
|
||||
|
||||
#pragma code ( bcode2 )
|
||||
#pragma data ( bdata2 )
|
||||
|
||||
void print2(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is second overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode3 )
|
||||
#pragma data ( bdata3 )
|
||||
|
||||
void print3(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is third overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode4 )
|
||||
#pragma data ( bdata4 )
|
||||
|
||||
void print4(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fourth overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode5 )
|
||||
#pragma data ( bdata5 )
|
||||
|
||||
void print5(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is fifth overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
#pragma code ( bcode6 )
|
||||
#pragma data ( bdata6 )
|
||||
|
||||
void print6(void)
|
||||
{
|
||||
cwin_put_string(&cw, p"This is sixth overlay", 7);
|
||||
cwin_cursor_newline(&cw);
|
||||
}
|
||||
|
||||
// Switching code generation back to shared section
|
||||
|
||||
#pragma code ( code )
|
||||
#pragma data ( data )
|
||||
|
||||
// Load an overlay section into memory
|
||||
|
||||
void load(const char * fname)
|
||||
{
|
||||
krnio_setnam(fname);
|
||||
if (krnio_open(2, 8, 2))
|
||||
{
|
||||
if (krnio_chkin(2))
|
||||
{
|
||||
char lo = krnio_chrin();
|
||||
char hi = krnio_chrin();
|
||||
|
||||
char * dp = (char *)((hi << 8) | lo);
|
||||
krnio_clrchn();
|
||||
krnio_read_lzo(2, dp);
|
||||
}
|
||||
krnio_close(2);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Kernal memory only
|
||||
mmap_set(MMAP_NO_BASIC);
|
||||
|
||||
// Init VIC
|
||||
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1800);
|
||||
|
||||
// Prepare output window
|
||||
cwin_init(&cw, (char *)0x0400, 0, 0, 40, 25);
|
||||
cwin_clear(&cw);
|
||||
|
||||
// Call function in overlay 1
|
||||
load(P"OVL1");
|
||||
print1();
|
||||
|
||||
// Call function in overlay 2
|
||||
load(P"OVL2");
|
||||
print2();
|
||||
|
||||
load(P"OVL3");
|
||||
print3();
|
||||
|
||||
load(P"OVL4");
|
||||
print4();
|
||||
|
||||
load(P"OVL5");
|
||||
print5();
|
||||
|
||||
load(P"OVL6");
|
||||
print6();
|
||||
|
||||
mmap_set(MMAP_ROM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <c64/asm6502.h>
|
||||
|
||||
// Invoke resident section with "SYS 49152" from basic
|
||||
|
||||
// not much space, so we go with a smaller stack size
|
||||
|
||||
#pragma stacksize(256)
|
||||
|
||||
// shrink size of startup section
|
||||
|
||||
#pragma section(startup, 0);
|
||||
#pragma region(startup, 0x0801, 0x0870, , , { startup } )
|
||||
|
||||
// section for code copy
|
||||
|
||||
#pragma section(rcode, 0)
|
||||
#pragma region(rcode, 0x0870, 0x0900, , , { rcode } )
|
||||
|
||||
// main section to stay resident, save three bytes at the
|
||||
// beginning to have space for an entry jump
|
||||
|
||||
#pragma region(main, 0x0903, 0x1900, , , {code, data, bss, heap, stack}, 0xc003 )
|
||||
|
||||
// resident entry routine
|
||||
|
||||
void tsr(void)
|
||||
{
|
||||
// Initialize stack pointer
|
||||
|
||||
__asm {
|
||||
lda #$ff
|
||||
sta __sp
|
||||
lda #$cf
|
||||
sta __sp +1
|
||||
}
|
||||
|
||||
// do something useless
|
||||
|
||||
printf(p"Hello World\n");
|
||||
|
||||
// and done
|
||||
}
|
||||
|
||||
// Now the copy code section
|
||||
|
||||
#pragma code(rcode)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// source and target address to copy, no memcpy as it is itself
|
||||
// not yet copied
|
||||
|
||||
char * dp = (char *)0xc000;
|
||||
char * sp = (char *)0x0903;
|
||||
|
||||
// A jmp to the code at the absolute address 0xc000 / 49152
|
||||
|
||||
dp += asm_ab(dp, ASM_JMP, (unsigned)tsr);
|
||||
|
||||
// then the code
|
||||
|
||||
for(unsigned i=0; i<0xffd; i++)
|
||||
*dp++ = *sp++;
|
||||
|
||||
// now we are done
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user