More conio fun. Add some ifndefs

master
Astoria 2 years ago
parent 067a4c5e0e
commit 465881c9b2

@ -2,6 +2,7 @@ LD = ../bin/ld65
AS = ../bin/ca65
CC = ../bin/cc65
AL = ../bin/align
CL = ../bin/cl65
CINCLUDE = -I../include
CFLAGS = -t none --cpu $(CPU)
@ -24,8 +25,8 @@ all: $(IMAGES)
%.o: %.s
$(AS) $(CFLAGS) $<
%.img: %.o
$(LD) $(LFLAGS) $< $(LLIBS) -o $@
%.img: %.o conio.o
$(LD) $(LFLAGS) $< conio.o $(LLIBS) -o $@
$(AL) $@

@ -1,31 +1,24 @@
#include "conio.h"
#include <string.h>
#include <redbus.h>
#include <console.h>
#define redbus 0x0300
int conid = 0x01;
Console* con = (Console*)redbus;
char * strinv(char str[]) {
int i;
for(i = 0; i < strlen(str); i++){
str[i] = inv(str[i]);
}
return str;
}
void conprint(char str[], int x, int y, int mode){
con = (Console*)redbus;
void conprint(char * str, int x, int y){
rb_map_device(conid);
str_size = strlen(str);
con->cursor_mode = mode;
line = y;
con->line = line;
for (i = 0; i < str_size; i++){
if (((y % 50) + (x + i) / 80) != line) {
line = (y % 50) + (x + i) / 80;
con->line = line;
}
con->display[(int)(x + i) % 80] = str[i];
}
con->line = y;
memcpy(con->display + x, str, strlen(str));
}
void set_conid(int id){
@ -34,4 +27,29 @@ void set_conid(int id){
int get_conid(){
return conid;
}
struct cursor_pos {
int x;
int y;
};
void set_cursor_pos(int x, int y) {
con->cursor_x = x;
con->cursor_y = y;
}
struct cursor_pos get_cursor_pos() {
struct cursor_pos cursor;
cursor.x = con->cursor_x;
cursor.y = con->cursor_y;
return cursor;
}
void set_cursor_mode(int mode) {
con->cursor_mode = mode;
}
int get_cursor_mode() {
return con->cursor_mode;
}

@ -1,6 +1,9 @@
int i;
int line;
int str_size;
Console* con;
#ifndef CONIO_H
#define CONIO_H
char * strinv(char str[]);
void conprint(char str[], int x, int y, int mode);
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();
#endif

@ -21,5 +21,6 @@ void main() {
rb_map_device(IOXID);
expand->out = 0;
output = (int*)expand->in;
conprint(strinv("Huzzah, inverted text!"), 0, 0, 3);
conprint("aeiou", 0, 0);
set_cursor_pos(5,5);
}

@ -1,3 +1,5 @@
#ifndef RB_CONSOLE
#define RB_CONSOLE
//console.h
// 0x00 Memory access row. Used to set which line of characters appears in the display memory window.
@ -52,4 +54,4 @@ typedef struct Console {
#define invert(x, y, w, h) blit(2, 0, 0, x, y, w, h)
#define scroll(x, y, ox, oy, w, h) blit(3, x, y, ox, oy, w, h)
#endif

Loading…
Cancel
Save