Probably trash, dont remember what exactly this all is

master
Astoria 2 years ago
parent 49a074912e
commit ef7e772d20

@ -0,0 +1,35 @@
LD = ../bin/ld65
AS = ../bin/ca65
CC = ../bin/cc65
AL = ../bin/align
CINCLUDE = -I../include
CFLAGS = -t none --cpu $(CPU)
LFLAGS = -C ../lib/rpc8e.cfg
LLIBS = ../lib/rpc8e.lib
#gonna leave this here for now
CPU = 65c02
IMAGES = astoriaTest.img
.PHONY: all
all: $(IMAGES)
%.s: %.c
$(CC) $(CFLAGS) $(CINCLUDE) $<
%.o: %.s
$(AS) $(CFLAGS) $<
%.img: %.o test.o
$(LD) $(LFLAGS) $< test.o $(LLIBS) -o $@
$(AL) $@
clean:
rm *.o *.s
.SUFFIXES:

@ -0,0 +1,63 @@
#include <redbus.h>
#include <console.h>
#include "test.h"
#define RB 0x0300
#define LSTREAM 47
#define SCREEN_W 80
#define SCREEN_H 50
Console* con;
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
}
void linefeed() {
scroll(0,1,0,0,SCREEN_W,SCREEN_H-3);
fill(0x20,0,LSTREAM,SCREEN_W,1);
}
unsigned char cursor = 0;
void print(char* buffer) {
unsigned char i = 0;
if(buffer[0] == 0) return;
con->line = LSTREAM;
if(cursor == 0) linefeed();
while(buffer[i] != 0 && i < 128) {
if(buffer[i] == '\n' || cursor == 80) {
cursor = 0;
linefeed();
} else {
con->display[cursor] = buffer[i];
++cursor;
}
++i;
}
if(i < 128)
cursor = 0;
}
void init_tests() {
rb_set_window((void*)RB);
con = (Console*)RB;
rb_enable();
}
void main(){
print("test");
}

@ -0,0 +1,181 @@
//irc_client.c
#include <redbus.h>
#include <console.h>
#include <disk.h>
#define RB 0x0300
Console* con;
Disk* dis;
#define DSTAT 32
#define DOUT 31
#define DIN 30
#define LPROMPT 49
#define LSTAT 48
#define LSTREAM 47
#define SCREEN_W 80
#define SCREEN_H 50
#define map_con() rb_map_device(0x01);
#define map_dis() rb_map_device(0x02);
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
void prepare_screen() {
map_con();
fill(0x20,0,0,SCREEN_W,SCREEN_H);
invert(0,LSTAT,SCREEN_W,1);
con->cursor_x = 0;
con->cursor_y = LPROMPT;
con->cursor_mode = 2;
}
char send = 0;
char recv = 0;
char outbuf[128];
char inbuf[128];
#define CONTROL 0
#define READPTR 1
#define WRITEPTR 2
unsigned char flush() {
dis->command = WRITE;
while(dis->command != IDLE && dis->command != FAIL) ;
return dis->command;
}
unsigned char wait() {
dis->command = READ;
while(dis->command != IDLE && dis->command != FAIL) ;
return dis->command;
}
void prepare_disk() {
map_dis();
dis->sector_num = DSTAT;
dis->sector[CONTROL] = 'N';
flush();
}
unsigned char cursor = 0;
void linefeed() {
scroll(0,1,0,0,SCREEN_W,SCREEN_H-3);
fill(0x20,0,LSTREAM,SCREEN_W,1);
}
void print(char* buffer) {
unsigned char i = 0;
if(buffer[0] == 0) return;
con->line = LSTREAM;
if(cursor == 0) linefeed();
while(buffer[i] != 0 && i < 128) {
if(buffer[i] == '\n' || cursor == 80) {
cursor = 0;
linefeed();
} else {
con->display[cursor] = buffer[i];
++cursor;
}
++i;
}
if(i < 128)
cursor = 0;
}
void read_keyboard() {
con->line = LPROMPT;
while(con->kb_pos != con->kb_start) {
outbuf[con->cursor_x] = con->kb_key;
if(con->kb_key == LF) {
outbuf[con->cursor_x+1] = 0;
fill(0x20,0,LPROMPT,SCREEN_W,1);
send = 1;
con->cursor_x = 0;
++con->kb_start;
break;
}
con->display[con->cursor_x] = con->kb_key;
++con->cursor_x;
++con->kb_start;
}
}
void perform_io() {
unsigned int i = 0;
map_dis();
i = 0;
dis->sector_num = DIN;
wait();
while(dis->sector[i] != 0 && i < 128) {
inbuf[i] = dis->sector[i];
dis->sector[i] = 0;
++i;
}
inbuf[i] = 0;
flush();
i = 0;
dis->sector_num = DOUT;
if(send == 1) {
while(outbuf[i] != 0 && i < 128) {
dis->sector[i] = outbuf[i];
++i;
}
//send = 0;
} else dis->sector[i] == 0;
if(!flush() && send == 1) send = 0;
map_con();
}
void main() {
rb_set_window((void*)RB);
con = (Console*)RB;
dis = (Disk*)RB;
rb_enable();
prepare_screen();
print("IRC for RPC8/e\nInitializing IO buffer space... ");
prepare_disk();
map_con();
print("[DONE]\nStarting IO loop.");
while(1) {
read_keyboard();
perform_io();
print(inbuf);
inbuf[0] = 0;
}
}

@ -0,0 +1,59 @@
#include <redbus.h>
#include <console.h>
#include "test.h"
#define RB 0x0300
#define LSTREAM 47
#define SCREEN_W 80
#define SCREEN_H 50
Console* con;
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
}
void linefeed() {
scroll(0,1,0,0,SCREEN_W,SCREEN_H-3);
fill(0x20,0,LSTREAM,SCREEN_W,1);
}
unsigned char cursor = 0;
void print(char* buffer) {
unsigned char i = 0;
if(buffer[0] == 0) return;
con->line = LSTREAM;
if(cursor == 0) linefeed();
while(buffer[i] != 0 && i < 128) {
if(buffer[i] == '\n' || cursor == 80) {
cursor = 0;
linefeed();
} else {
con->display[cursor] = buffer[i];
++cursor;
}
++i;
}
if(i < 128)
cursor = 0;
}
void init_tests() {
rb_set_window((void*)RB);
con = (Console*)RB;
rb_enable();
}

@ -0,0 +1,4 @@
void init_tests();
void print(char* buffer);
#define TEST(NAME, COND) print(NAME); print(#COND); if((COND)) print("PASS\n"); else print("FAIL\n")

@ -0,0 +1,304 @@
;
; File generated by cc65 v 2.13.3
;
.fopt compiler,"cc65 v 2.13.3"
.setcpu "65C02"
.smart on
.autoimport on
.case on
.debuginfo off
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
.macpack longbranch
.import _rb_enable
.import _rb_set_window
.export _init_tests
.export _print
.export _con
.export _blit
.export _linefeed
.export _cursor
.segment "DATA"
_cursor:
.byte $00
.segment "BSS"
_con:
.res 2,$00
; ---------------------------------------------------------------
; void __near__ init_tests (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _init_tests: near
.segment "CODE"
ldx #$03
lda #$00
jsr _rb_set_window
ldx #$03
lda #$00
sta _con
stx _con+1
jsr _rb_enable
rts
.endproc
; ---------------------------------------------------------------
; void __near__ print (__near__ unsigned char*)
; ---------------------------------------------------------------
.segment "CODE"
.proc _print: near
.segment "CODE"
lda #$00
jsr pusha
ldy #$02
jsr ldaxysp
ldy #$00
jsr ldauidx
cmp #$00
jsr booleq
jeq L0029
jmp L0045
L0029: lda _con
ldx _con+1
jsr pushax
ldx #$00
lda #$2F
ldy #$00
jsr staspidx
ldx #$00
lda _cursor
cmp #$00
jsr booleq
jeq L002E
jsr _linefeed
L002E: ldy #$02
jsr ldaxysp
jsr pushax
ldy #$02
ldx #$00
lda (sp),y
jsr tosaddax
ldy #$00
jsr ldauidx
cmp #$00
jsr boolne
jeq L0035
ldy #$00
ldx #$00
lda (sp),y
cmp #$80
jsr boolult
jne L0033
L0035: ldx #$00
lda #$00
jeq L0036
L0033: ldx #$00
lda #$01
L0036: jeq L0032
ldy #$02
jsr ldaxysp
jsr pushax
ldy #$02
ldx #$00
lda (sp),y
jsr tosaddax
ldy #$00
jsr ldauidx
cmp #$0A
jsr booleq
jne L0038
ldx #$00
lda _cursor
cmp #$50
jsr booleq
jne L0038
ldx #$00
lda #$00
jeq L003A
L0038: ldx #$00
lda #$01
L003A: jeq L0037
ldx #$00
lda #$00
sta _cursor
jsr _linefeed
jmp L003E
L0037: lda _con
ldx _con+1
ldy #$10
jsr incaxy
jsr pushax
ldx #$00
lda _cursor
jsr tosaddax
jsr pushax
ldy #$04
jsr ldaxysp
jsr pushax
ldy #$04
ldx #$00
lda (sp),y
jsr tosaddax
ldy #$00
jsr ldauidx
ldy #$00
jsr staspidx
ldx #$00
inc _cursor
lda _cursor
L003E: ldy #$00
ldx #$00
clc
lda #$01
adc (sp),y
sta (sp),y
jmp L002E
L0032: ldy #$00
ldx #$00
lda (sp),y
cmp #$80
jsr boolult
jeq L0045
ldx #$00
lda #$00
sta _cursor
L0045: jsr incsp3
rts
.endproc
; ---------------------------------------------------------------
; void __near__ blit (unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)
; ---------------------------------------------------------------
.segment "CODE"
.proc _blit: near
.segment "CODE"
lda _con
ldx _con+1
jsr pushax
ldy #$07
ldx #$00
lda (sp),y
ldy #$08
jsr staspidx
lda _con
ldx _con+1
jsr pushax
ldy #$06
ldx #$00
lda (sp),y
ldy #$09
jsr staspidx
lda _con
ldx _con+1
jsr pushax
ldy #$05
ldx #$00
lda (sp),y
ldy #$0A
jsr staspidx
lda _con
ldx _con+1
jsr pushax
ldy #$04
ldx #$00
lda (sp),y
ldy #$0B
jsr staspidx
lda _con
ldx _con+1
jsr pushax
ldy #$03
ldx #$00
lda (sp),y
ldy #$0C
jsr staspidx
lda _con
ldx _con+1
jsr pushax
ldy #$02
ldx #$00
lda (sp),y
ldy #$0D
jsr staspidx
lda _con
ldx _con+1
jsr pushax
ldy #$08
ldx #$00
lda (sp),y
ldy #$07
jsr staspidx
L0012: lda _con
ldx _con+1
ldy #$07
jsr ldauidx
cmp #$00
jsr boolne
jeq L0013
jmp L0012
L0013: jsr incsp7
rts
.endproc
; ---------------------------------------------------------------
; void __near__ linefeed (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _linefeed: near
.segment "CODE"
lda #$03
jsr pusha
lda #$00
jsr pusha
lda #$01
jsr pusha
lda #$00
jsr pusha
lda #$00
jsr pusha
lda #$50
jsr pusha
lda #$2F
jsr pusha
jsr _blit
lda #$01
jsr pusha
lda #$20
jsr pusha
lda #$00
jsr pusha
lda #$00
jsr pusha
lda #$2F
jsr pusha
lda #$50
jsr pusha
lda #$01
jsr pusha
jsr _blit
rts
.endproc

@ -0,0 +1,22 @@
//test_rb.c
#include <redbus.h>
#include <console.h>
#define redbus 0x0300
#define default_console_id 0x01
void main() {
Console* console;
rb_set_window((void*)redbus);
rb_map_device(default_console_id);
rb_enable();
console = (Console*)redbus;
console->cursor_mode = 2;
console->display[0] = 'X';
console->display[1] = inv('Y');
}

@ -0,0 +1,48 @@
#include <stdlib.h>
#include "test.h"
// void* malloc (size_t size);
// void* calloc (size_t count, size_t size);
// void* realloc (void* block, size_t size);
// void free (void* block);
// void _heapadd (void* mem, size_t size);
// size_t _heapblocksize (const void* block);
// size_t _heapmemavail (void);
// size_t _heapmaxavail (void);
// int rand (void);
// void srand (unsigned seed);
// void _randomize (void);
// void abort (void);
//// int abs (int val);
// long labs (long val);
//// int atoi (const char* s);
// long atol (const char* s);
// int atexit (void (*exitfunc) (void));
// void* bsearch (const void* key, const void* base, size_t n, size_t size, int (*cmp) (const void*, const void*));
// div_t div (int numer, int denom);
// void exit (int ret);
// char* getenv (const char* name);
// void qsort (void* base, size_t count, size_t size, int (*compare) (const void*, const void*));
// long strtol (const char* nptr, char** endptr, int base);
// unsigned long strtoul (const char* nptr, char** endptr, int base);
// int system (const char* s);
// void _swap (void* p, void* q, size_t size);
//// char* itoa (int val, char* buf, int radix);
// char* utoa (unsigned val, char* buf, int radix);
// char* ltoa (long val, char* buf, int radix);
// char* ultoa (unsigned long val, char* buf, int radix);
// int putenv (char* s);
void main()
{
char temp[5];
init_tests();
TEST("abs", 1 == abs(-1));
TEST("abs", 0xFAF == abs(0xFAF));
TEST("itoa-atoi", 257 == atoi(itoa(257, temp, 10)));
}
Loading…
Cancel
Save