Sortron shenanigans

master
Astoria 1 year ago
parent 98afb2359f
commit e4e0d057cc

@ -2,6 +2,7 @@ LD = ../bin/ld65
AS = ../bin/ca65
CC = ../bin/cc65
AL = ../bin/align
DA = /home/astoria/bin/da65
CINCLUDE = -I../include
CFLAGS = -t none --cpu $(CPU)
@ -32,9 +33,23 @@ all: $(IMAGES)
clean:
rm *.o *.s
.PHONY: test
.PHONY: testemu
test: test_iox.img
testemu: test_iox.img
emu65el02 test_iox.img
.PHONY: testgame
testgame: test_iox.img
touch /home/astoria/.local/share/PolyMC/instances/WOAHITSBACK/.minecraft/saves/New\ World-/redpower/disk_09e74aca3d58e92a.img
rm /home/astoria/.local/share/PolyMC/instances/WOAHITSBACK/.minecraft/saves/New\ World-/redpower/disk_09e74aca3d58e92a.img
cp test_iox.img /home/astoria/.local/share/PolyMC/instances/WOAHITSBACK/.minecraft/saves/New\ World-/redpower/disk_09e74aca3d58e92a.img
.PHONY: devgame
devgame: test_iox.img
touch /home/astoria/Downloads/redpower/saves/New\ World/redpower/disk_b2f279b88ec3d8f5.img
rm /home/astoria/Downloads/redpower/saves/New\ World/redpower/disk_b2f279b88ec3d8f5.img
cp test_iox.img /home/astoria/Downloads/redpower/saves/New\ World/redpower/disk_b2f279b88ec3d8f5.img
.SUFFIXES:

@ -1,12 +1,10 @@
#include "conio.h"
#include <string.h>
#include <redbus.h>
#include <console.h>
#define redbus 0x0300
int conid = 0x01;
Console* con = (Console*)redbus;
//Slow, find how str function does it and apply to whole string at once?
//Technically could be void, but with returning string allows you to use it easy.
char * strinv(char str[]) {
int i;
for(i = 0; i < strlen(str); i++){
@ -14,10 +12,10 @@ char * strinv(char str[]) {
}
return str;
}
//This is currently unable to screenwrap. Improve in the future.
void conprint(char * str, int x, int y){
rb_map_device(conid);
con->line = y;
con->line = y % 50;
memcpy(con->display + x, str, strlen(str));
}
@ -35,21 +33,82 @@ struct cursor_pos {
};
void set_cursor_pos(int x, int y) {
rb_map_device(conid);
con->cursor_x = x;
con->cursor_y = y;
}
struct cursor_pos get_cursor_pos() {
struct cursor_pos cursor;
rb_map_device(conid);
cursor.x = con->cursor_x;
cursor.y = con->cursor_y;
return cursor;
}
void set_cursor_mode(int mode) {
rb_map_device(conid);
con->cursor_mode = mode;
}
int get_cursor_mode() {
rb_map_device(conid);
return con->cursor_mode;
}
void conclear(){
rb_map_device(conid);
blit(1, ' ', (char)0xBD, 0, 0, 80, 50);
set_cursor_pos(0,0);
}
void blit(char command, char x, char y, char xo, char yo, char w, char h) {
con->blit_start_x = x;
con->blit_start_y = y;
con->blit_offset_x = xo;
con->blit_offset_y = yo;
con->blit_width = w;
con->blit_height = h;
con->blit_mode = command;
while(con->blit_mode != 0) ; //WAI
}
#define LF 13
#define BSP 8
char * read_keyboard() {
int pos = 0;
char buf[128];
int breakpoint = 1;
int cursorp;
rb_map_device(conid);
memset(buf, 0, 128);
cursorp = con->cursor_x;
con->line = con->cursor_y;
while(breakpoint) {
while(con->kb_pos != con->kb_start && breakpoint) {
switch(con->kb_key) {
case LF :
fill(' ', cursorp, con->cursor_y, con->cursor_x, 1);
con->cursor_x = cursorp;
breakpoint = 0;
con->kb_start++;
break;
case BSP :
con->kb_pos--;
con->cursor_x--;
pos--;
buf[pos] = ' ';
con->display[con->cursor_x] = ' ';
break;
default :
buf[pos] = con->kb_key;
con->display[con->cursor_x] = con->kb_key;
con->cursor_x++;
con->kb_start++;
pos++;
break;
}
}
}
return buf;
}

@ -1,9 +1,21 @@
#ifndef CONIO_H
#define CONIO_H
#include <redbus.h>
#include <console.h>
#define redbus 0x0300
int conid = 0x01;
Console* con = (Console*)redbus;
char * strinv(char str[]);
void conprint(char * str, int x, int y);
void set_conid(int id);
int get_conid();
void set_cursor_pos(int x, int y);
void set_cursor_mode(int mode);
int get_cursor_mode();
void conclear();
void blit(char command, char x, char y, char xo, char yo, char w, char h);
char * read_keyboard();
#endif

@ -0,0 +1,10 @@
default_monitor_id=1
default_drive_id=2
cpu_speed=1x
mmu_type=original
io_penality=on
drive_boost=off
memory_size=8kb
spbugfix=disabled
dev_1=2
dev_2=3

@ -4,8 +4,9 @@
#include <console.h>
#include <iox.h>
#include "test_iox.h"
#include <string.h>
#include "conio.c"
#include "conio.h"
#include <stdlib.h>
#include <sortron.h>
#define redbus 0x0300
#define IOXID 0x03
@ -15,12 +16,16 @@ Iox* expand;
int* output;
void main() {
Sortron* sort = (Sortron*)redbus;
int status;
rb_set_window((void*)redbus);
rb_map_device(0x04);
rb_enable();
expand = (Iox*)redbus;
rb_map_device(IOXID);
expand->out = 0;
output = (int*)expand->in;
conprint("aeiou FANTASTIQUE!", 0, 0);
set_cursor_pos(5,5);
sort->slot = 1;
sort->quantity = 5;
sort->command = EJECT;
rb_map_device(conid);
conprint("f", 0, 5);
conprint(itoa(sizeof(long), 0, 10), 0, 0);
}

@ -14,7 +14,7 @@
// 0x07 blit mode (1: fill, 2: invert; 3: shift)
// 0x08 blit x start / fill value
// 0x09 blit y start
// 0x09 blit y start / fill color
// 0x0A blit x offset
// 0x0B blit y offset
// 0x0C blit width
@ -43,11 +43,14 @@ typedef struct Console {
unsigned int padding;
char display[0x50];
char colors[0x50];
} Console;
//character with inverted colors
#define inv(c) ((c) | 0x80)
//Originally commented out? Not sure why, there is a working blit in the test programs. Ive copied that over to conio.h so, this will stay commented out.
//void blit(char command, char x, char y, char xo, char yo, char w, char h);
#define fill(b, x, y, w, h) blit(1, b, 0, x, y, w, h)

@ -1,3 +1,5 @@
#ifndef RB_SORTRON
#define RB_SORTRON
// sortron.h
// SORTRON DOCUMENTATION
@ -30,4 +32,34 @@
// $0C: output color
// 0 is none, 1-16 is white-black
// $0D: input color
// $0D: input color
typedef enum {
IDLE = (char)0,
GETSLOTS = (char)1,
GETMETA = (char)2,
EJECT = (char)3,
ACCEPT = (char)4,
FAIL = (char)0xFF
} SortCommand;
typedef struct Sortron {
//0
char command;
// 1
char quantity;
// 2 3
int slot;
// 4 5 6 7
unsigned long id;
// 8 9
unsigned int damage;
// A B
unsigned int max_damage;
// C
char colorout;
// D
char colorin;
} Sortron;
#endif
Loading…
Cancel
Save