Skip to content

Commit

Permalink
c64: updates, .ca65 -> .s, joystick #2
Browse files Browse the repository at this point in the history
  • Loading branch information
sehugg committed Nov 5, 2024
1 parent 19c2032 commit a91b721
Show file tree
Hide file tree
Showing 32 changed files with 91 additions and 87 deletions.
6 changes: 3 additions & 3 deletions presets/c64/climber.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

#include "sidplaysfx.h"
//#resource "sidmusic1.bin"
//#link "sidplaysfx.ca65"
//#link "sidplaysfx.s"

#include "rasterirq.h"
//#link "rasterirq.ca65"
//#link "rasterirq.s"

#include "bcd.h"
//#link "bcd.c"
Expand Down Expand Up @@ -647,7 +647,7 @@ void pickup_object(Actor* actor) {
}

void move_player() {
char joy = joy_read(0);
char joy = joy_read(1);
move_actor(&actors[0], joy, true);
pickup_object(&actors[0]);
}
Expand Down
2 changes: 1 addition & 1 deletion presets/c64/digisound.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void main(void) {
clrscr();
digi_setup();
while (1) {
digi_play(digisound, 0xacf8L);
digi_play(digisound, sizeof(digisound));
printf("\nPress ENTER to restart digi...\n");
getchar();
}
Expand Down
2 changes: 1 addition & 1 deletion presets/c64/fld.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//#link "common.c"

#include "rasterirq.h"
//#link "rasterirq.ca65"
//#link "rasterirq.s"

#include "bcd.h"
//#link "bcd.c"
Expand Down
64 changes: 22 additions & 42 deletions presets/c64/fullscrollgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "sprites.h"
//#link "sprites.c"

//#link "level2.ca65"
//#link "level2.s"

#define CAMERA_OFFSET_X 158
#define CAMERA_OFFSET_Y 120
Expand Down Expand Up @@ -57,8 +57,8 @@ extern const byte chartileset_tag_data[];
extern const byte map_data[];


static byte framecount;
static byte framemask;
static byte framecount; // frame counter
static byte framemask; // single bit rotates each frame

const byte BITMASKS[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };

Expand Down Expand Up @@ -112,17 +112,18 @@ static void build_tile_flag_map(void) {
}
}

static void draw_cell(word ofs, byte scrn_x, byte scrn_y) {
byte ch, color;
void draw_cell(word ofs, byte scrn_x, byte scrn_y) {
byte ch, color; // character and color to draw
// get the character and color from the level map
if (get_cell_at(scrn_x + origin_x, scrn_y + origin_y)) {
ch = tilechar;
color = chartileset_colour_data[tileindex];
ch = tilechar; // character from tileset
color = chartileset_colour_data[tileindex]; // color from tileset
} else {
ch = DEFAULT_CHAR;
color = DEFAULT_COLOR;
ch = DEFAULT_CHAR; // default character
color = DEFAULT_COLOR; // default color
}
hidbuf[ofs] = ch;
colorbuf[ofs] = color;
hidbuf[ofs] = ch; // draw character to hidden buffer
colorbuf[ofs] = color; // draw color to color buffer
}

void scroll_draw_column(byte col) {
Expand Down Expand Up @@ -273,12 +274,12 @@ typedef enum {
} ActorState;

typedef struct Actor {
word xx;
word yy;
sbyte xvel;
sbyte yvel;
word xx; // X coord
word yy; // Y coord
sbyte xvel; // X velocity
sbyte yvel; // Y velocity
ActorState state;
bool faceleft;
bool faceleft; // facing left?
} Actor;

Actor actors[MAX_ACTORS];
Expand All @@ -290,7 +291,7 @@ void draw_actor(register Actor* actor, byte index) {
word xpos = actor->xx + pixofs_x + fine_correct_x + ACTOR_OFFSET_X;
word ypos = actor->yy + pixofs_y + fine_correct_y + ACTOR_OFFSET_Y;
if (xpos > 320 || ypos > 250) {
ypos = 255;
ypos = 255; // hide the sprite
}
switch (actor->state) {
case STANDING:
Expand Down Expand Up @@ -318,23 +319,10 @@ const char velocity_bitmasks[8] = {
0b01110101, // 5/8
0b11101110, // 6/8
0b11110111, // 7/8
// 0b11111111, // 8/8
};

static byte box[4]; // hit box

/*
void actor_set_position(register Actor* actor,
word world_x,
word world_y,
ActorState state) {
actor->xx = world_x;
actor->yy = world_y;
actor->state = state;
actor->tileindex = (world_x>>5) | (world_y>>5)*MAP_COLS;
}
*/

void move_actor(register Actor* actor,
sbyte cmd_dx,
sbyte cmd_dy) {
Expand Down Expand Up @@ -553,7 +541,7 @@ void next_frame() {
// increment frame counter
framemask = BITMASKS[++framecount & 7];
// get joystick bits
joy = joy_read(0);
joy = joy_read(1);
// move player
control_actor(player, joy);
// move enemy
Expand Down Expand Up @@ -615,20 +603,12 @@ void main(void) {
// repaint screen memory w/ the map
scroll_refresh();

player->xx = 3*32+8;
player->yy = 2*32+8-16;

// set player initial position
player->xx = 0;
player->yy = 31;
player->state = STANDING;
/*
player->xx = 32;
player->yy = 0;
player->xx = 33;
player->yy = 100;
player->state = JUMPING;
*/
// actor_set_position(player, 63, 63, STANDING);

// set other actor's initial position
actors[1].xx = 128;

// infinite loop
Expand Down
2 changes: 1 addition & 1 deletion presets/c64/joygame.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void main(void) {
sprite_update(DEFAULT_SCREEN);

// get joystick bits
joy = joy_read(0);
joy = joy_read(1);
move_player(joy);
// move other objects
move_non_players();
Expand Down
2 changes: 1 addition & 1 deletion presets/c64/joymove.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void main(void) {
// loop forever
while (1) {
// get joystick bits
joy = joy_read(0);
joy = joy_read(1);
// move sprite based on joystick
if (JOY_LEFT(joy)) { x -= 1; } // move left 1 pixel
if (JOY_RIGHT(joy)) { x += 1; } // move right 1 pixel
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion presets/c64/linecrunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//#link "common.c"

#include "rasterirq.h"
//#link "rasterirq.ca65"
//#link "rasterirq.s"

#include "bcd.h"
//#link "bcd.c"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion presets/c64/musicplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ char music_update() {

void handleInput() {
char key = 0;
char joy = joy_read(0);
char joy = joy_read(1);
if (joy == 0) return;
if (JOY_UP(joy)) key = 'i';
if (JOY_DOWN(joy)) key = 'k';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion presets/c64/scroll3.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void main(void) {
// infinite loop
while (1) {
// get joystick bits
char joy = joy_read(0);
char joy = joy_read(1);
// move sprite based on arrow keys
if (JOY_LEFT(joy)) scroll_horiz(-1);
if (JOY_UP(joy)) scroll_vert(-1);
Expand Down
2 changes: 1 addition & 1 deletion presets/c64/scroll4.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void main(void) {
while (1) {
static char speed = 1;
// get joystick bits
char joy = joy_read(0);
char joy = joy_read(1);
// speed up scrolling while button pressed
speed = JOY_BTN_1(joy) ? 2 : 1;
// move sprite based on arrow keys
Expand Down
2 changes: 1 addition & 1 deletion presets/c64/scroll5.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void main(void) {
static char joy;
static bool slowframe = false;
// get joystick bits
joy = joy_read(0);
joy = joy_read(1);
// speed up scrolling while button pressed
speed = JOY_BTN_1(joy) ? 3 : 1;
// if we copied screen memory last frame,
Expand Down
2 changes: 1 addition & 1 deletion presets/c64/scrolling_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//#link "common.c"

#include "rasterirq.h"
//#link "rasterirq.ca65"
//#link "rasterirq.s"

// generated from https://8bitworkshop.com/bitmapfontgenerator/
// 16 x 32 MSB first y offset 6 Terminus
Expand Down
4 changes: 2 additions & 2 deletions presets/c64/scrollingmap1.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "sprites.h"
//#link "sprites.c"

//#link "level1.ca65"
//#link "level2.s"

extern const byte charset_data[];
extern const byte charset_attrib_data[];
Expand Down Expand Up @@ -152,7 +152,7 @@ void main(void) {
static char joy;
static bool slowframe = false;
// get joystick bits
joy = joy_read(0);
joy = joy_read(1);
// speed up scrolling while button pressed
speed = JOY_BTN_1(joy) ? 3 : 1;
// if we copied screen memory last frame,
Expand Down
4 changes: 2 additions & 2 deletions presets/c64/siddemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define CFGFILE c64-sid.cfg

//#resource "sidmusic1.bin"
//#link "sidplaysfx.ca65"
//#link "sidplaysfx.s"
#include "sidplaysfx.h"

static const unsigned char Palette[2] =
Expand Down Expand Up @@ -85,7 +85,7 @@ void main(void) {

while (1) {
// play sound effect when joystick is moved
byte joy = joy_read(0);
byte joy = joy_read(1);
if (joy) {
sid_sfx(joy & 3);
// exit when fire button pressed
Expand Down
4 changes: 2 additions & 2 deletions presets/c64/side_scroller.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//#link "sprites.c"

#include "rasterirq.h"
//#link "rasterirq.ca65"
//#link "rasterirq.s"

#include "bcd.h"
//#link "bcd.c"
Expand Down Expand Up @@ -332,7 +332,7 @@ void main() {
detect_player_collision(bg_coll, spr_coll);

// get joystick bits and move player
move_player(joy_read(0));
move_player(joy_read(1));

// move obstacle and powerup sprites
move_items();
Expand Down
File renamed without changes.
Loading

0 comments on commit a91b721

Please sign in to comment.