mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-28 08:50:22 +00:00
c64: presets use common.h
This commit is contained in:
parent
66017f8316
commit
cc8ce51f05
@ -1,10 +1,5 @@
|
||||
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <peekpoke.h>
|
||||
#include <string.h>
|
||||
#include <c64.h>
|
||||
#include "common.h"
|
||||
#include <cbm_petscii_charmap.h>
|
||||
|
||||
int matches; // number of matches remaining
|
||||
|
@ -1,26 +1,20 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <c64.h>
|
||||
#include <joystick.h>
|
||||
|
||||
//#resource "c64-sid.cfg"
|
||||
#define CFGFILE c64-sid.cfg
|
||||
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
#include "sidplaysfx.h"
|
||||
//#resource "sidmusic1.bin"
|
||||
//#link "sidplaysfx.ca65"
|
||||
#include "sidplaysfx.h"
|
||||
|
||||
//#link "rasterirq.ca65"
|
||||
#include "rasterirq.h"
|
||||
//#link "rasterirq.ca65"
|
||||
|
||||
#include "bcd.h"
|
||||
//#link "bcd.c"
|
||||
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
#include "scrolling.h"
|
||||
//#link "scrolling.c"
|
||||
|
||||
|
@ -1,8 +1,14 @@
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
#include <c64.h>
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <peekpoke.h>
|
||||
#include <string.h>
|
||||
#include <c64.h>
|
||||
#include <joystick.h>
|
||||
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t word;
|
||||
@ -14,8 +20,9 @@ typedef enum { false, true } bool;
|
||||
|
||||
#define DEFAULT_SCREEN ((void*)0x400)
|
||||
|
||||
#define wait_vblank waitvsync
|
||||
|
||||
void raster_wait(byte line);
|
||||
void wait_vblank(void);
|
||||
|
||||
char* get_vic_bank_start(void);
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <peekpoke.h>
|
||||
#include <string.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <joystick.h>
|
||||
#include "common.h"
|
||||
|
||||
/*{w:24,h:21,bpp:1,brev:1,count:1}*/
|
||||
const char SPRITE_DATA[64] = {
|
||||
|
@ -1,8 +1,3 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <c64.h>
|
||||
#include <peekpoke.h>
|
||||
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
@ -3,10 +3,6 @@
|
||||
A simple music player.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <c64.h>
|
||||
#include <_sid.h>
|
||||
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
|
@ -1,17 +1,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
|
||||
void rasterWait(unsigned char line) {
|
||||
while (VIC.rasterline < line) ;
|
||||
}
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
byte x = 0; // x scroll position
|
||||
byte y = 0; // y scroll position
|
||||
@ -39,7 +28,7 @@ void main(void) {
|
||||
VIC.ctrl2 = VIC.ctrl2 & 0xf8;
|
||||
VIC.ctrl2 |= (x & 7);
|
||||
// wait for vsync
|
||||
rasterWait(255);
|
||||
waitvsync();
|
||||
// every 8 pixels, move screen cells
|
||||
if ((x & 7) == 0) {
|
||||
memcpy(scrnbuf, scrnbuf+1, 40*8-1);
|
||||
|
@ -1,17 +1,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
|
||||
void rasterWait(unsigned char line) {
|
||||
while (VIC.rasterline < line) ;
|
||||
}
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
byte x = 0; // x scroll position
|
||||
byte y = 0; // y scroll position
|
||||
@ -49,7 +38,7 @@ void main(void) {
|
||||
src = scrnbuf[frame&1] + (x&7)*128;
|
||||
dst = scrnbuf[frame&1^1] + (x&7)*128;
|
||||
// wait for vsync
|
||||
rasterWait(255);
|
||||
waitvsync();
|
||||
// scroll hidden buffer
|
||||
memcpy(dst, src+1, 128);
|
||||
// every 8 pixels, switch farmes
|
||||
|
@ -1,27 +1,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <joystick.h>
|
||||
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t word;
|
||||
typedef int8_t sbyte;
|
||||
|
||||
#define COLS 40
|
||||
#define ROWS 25
|
||||
|
||||
void raster_wait(unsigned char line) {
|
||||
while (VIC.rasterline < line) ;
|
||||
}
|
||||
|
||||
void wait_vblank() {
|
||||
raster_wait(255); // TODO
|
||||
}
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
sbyte scroll_fine_x = 0;
|
||||
sbyte scroll_fine_y = 0;
|
||||
@ -129,7 +108,7 @@ void main(void) {
|
||||
if (JOY_RIGHT(joy)) scroll_horiz(1);
|
||||
if (JOY_DOWN(joy)) scroll_vert(1);
|
||||
// update regs
|
||||
wait_vblank();
|
||||
waitvsync();
|
||||
scroll_update_regs();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,4 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <joystick.h>
|
||||
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
@ -92,7 +83,7 @@ void main(void) {
|
||||
sprite_draw(0, n++, 70, 192);
|
||||
sprite_draw(0, 172, 145, 192);
|
||||
// wait for vblank
|
||||
wait_vblank();
|
||||
waitvsync();
|
||||
// update scroll registers
|
||||
// and swap screens if we must
|
||||
scroll_update();
|
||||
|
@ -1,13 +1,4 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <joystick.h>
|
||||
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
@ -124,8 +115,8 @@ void main(void) {
|
||||
slowframe = swap_needed;
|
||||
// animate sprite in shadow sprite ram
|
||||
update_player();
|
||||
// wait for vblank
|
||||
wait_vblank();
|
||||
// wait for end of frame
|
||||
waitvsync();
|
||||
// then update sprite registers
|
||||
sprite_update(visbuf);
|
||||
// update scroll registers
|
||||
|
@ -1,9 +1,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <joystick.h>
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
//#resource "c64-sid.cfg"
|
||||
#define CFGFILE c64-sid.cfg
|
||||
|
@ -3,33 +3,20 @@ Text-based version of a Blockade-style game.
|
||||
For more information, see "Making Arcade Games in C".
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <joystick.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <peekpoke.h>
|
||||
|
||||
#define COLS 40
|
||||
#define ROWS 24
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef signed char sbyte;
|
||||
typedef unsigned short word;
|
||||
#include "common.h"
|
||||
|
||||
// BASL = text address of cursor position
|
||||
static byte** BASL = (byte**) 0xD1;
|
||||
|
||||
byte getchar(byte x, byte y) {
|
||||
// get the character at a specfic x/y position
|
||||
byte readcharxy(byte x, byte y) {
|
||||
gotoxy(x,y); // set cursor position
|
||||
return (*BASL)[x]; // lookup value @ cursor address
|
||||
}
|
||||
|
||||
void delay(byte count) {
|
||||
while (count--) {
|
||||
word i;
|
||||
for (i=0; i<200; i++) ;
|
||||
waitvsync();
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +102,7 @@ void move_player(Player* p) {
|
||||
cputcxy(p->x, p->y, p->tail_attr);
|
||||
p->x += DIR_X[p->dir];
|
||||
p->y += DIR_Y[p->dir];
|
||||
if ((getchar(p->x, p->y) & 0x7f) != ' ')
|
||||
if ((readcharxy(p->x, p->y) & 0x7f) != ' ')
|
||||
p->collided = 1;
|
||||
draw_player(p);
|
||||
}
|
||||
@ -141,7 +128,8 @@ byte ai_try_dir(Player* p, dir_t dir, byte shift) {
|
||||
dir &= 3;
|
||||
x = p->x + (DIR_X[dir] << shift);
|
||||
y = p->y + (DIR_Y[dir] << shift);
|
||||
if (x < COLS && y < ROWS && (getchar(x, y) & 0x7f) == ' ') {
|
||||
if (x < COLS && y < ROWS
|
||||
&& (readcharxy(x, y) & 0x7f) == ' ') {
|
||||
p->dir = dir;
|
||||
return 1;
|
||||
} else {
|
||||
|
@ -1,12 +1,4 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
|
@ -1,11 +1,5 @@
|
||||
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <peekpoke.h>
|
||||
#include <string.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
#include "common.h"
|
||||
|
||||
/*{w:24,h:21,bpp:1,brev:1,count:1}*/
|
||||
const char SPRITE_DATA[64] = {
|
||||
|
@ -1,9 +1,4 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <c64.h>
|
||||
#include <cbm_petscii_charmap.h>
|
||||
|
||||
//#link "common.c"
|
||||
#include "common.h"
|
||||
|
||||
@ -13,6 +8,8 @@
|
||||
//#link "sprites.c"
|
||||
#include "sprites.h"
|
||||
|
||||
#include <cbm_petscii_charmap.h>
|
||||
|
||||
/*{w:24,h:21,bpp:1,brev:1}*/
|
||||
const char spriteshape[3*21] = {
|
||||
0x00,0x7F,0x00,0x01,0xFF,0xC0,0x03,0xFF,0xE0,
|
||||
|
@ -1,11 +1,7 @@
|
||||
// ported from
|
||||
// https://odensskjegg.home.blog/2018/12/29/recreating-the-commodore-64-user-guide-code-samples-in-cc65-part-three-sprites/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
#include <peekpoke.h>
|
||||
#include <c64.h>
|
||||
#include "common.h"
|
||||
|
||||
/*{w:24,h:21,bpp:1,brev:1}*/
|
||||
const char sprite[3*21] = {
|
||||
|
Loading…
Reference in New Issue
Block a user