Update SDC for F256K2e. Started ImageView sample

This commit is contained in:
Peter Weingartner 2024-09-10 21:49:39 -04:00
parent 74c953a46b
commit d526615245
33 changed files with 2471 additions and 8 deletions

View file

@ -151,6 +151,21 @@ int _Stub_close(int fd) {
return 0;
}
/****************************************************************************
* Name: _Stub_lseek
*
* Description:
* Change position in a file
*
* Returns the new position in the file in bytes from the beginning of the
* file, or -1 on failure.
*
****************************************************************************/
long _Stub_lseek(int fd, long offset, int whence) {
return 0;
}
/****************************************************************************
* Name: _Stub_read
*

View file

@ -0,0 +1,68 @@
# VPATH=.:../../module/Calypsi-remote-debug/src
DEBUGGER=../module/Calypsi-remote-debug/src
UNIT := F256K
MEMORY := RAM
# Define OS-dependent variables
ifeq ($(OS),Windows_NT)
RM = del /F/Q
else
RM = rm -f
endif
# Define model-specific variables, including tools, source files, compiler flags, etc.
ifeq ($(UNIT),F256K)
CPU=w65816
C_SRCS_DEBUGGER=$(DEBUGGER)/agent.c $(DEBUGGER)/c256-uart.c $(DEBUGGER)/low_level_WDC65816.s
SRCS_FOR_UNIT=
CFLAGS_FOR_UNIT=-DMODEL=17 -DCPU=255 --code-model large --data-model large
ifeq ($(MEMORY),ROM)
LDFLAGS_FOR_UNIT=clib-lc-ld.a --rtattr printf=medium --target=f256 # C256/f256-flash.scm
else
LDFLAGS_FOR_UNIT=f256-plain.scm clib-lc-ld.a --rtattr printf=medium --target=f256
endif
endif
ifeq ($(CPU),w65816)
CC=cc65816
AS=as65816
LD=ln65816
AR=nlib
endif
INCLUDES=-I. -I./include
CFLAGS=$(INCLUDES) $(CFLAGS_FOR_UNIT) -l # -l -D_CALYPSI_MCP_DEBUGGER
ASFLAGS=$(INCLUDES) --data-model large --code-model large
ifeq ($(MEMORY),ROM)
LDFLAGS=--rom-code $(LDFLAGS_FOR_UNIT) --list-file toolbox.map
else
LDFLAGS=$(LDFLAGS_FOR_UNIT) --list-file toolbox.map
endif
SRCS = imageview.c header.s $(SRCS_FOR_UNIT) # $(C_SRCS_DEBUGGER) ram-startup.s
OBJS = $(patsubst %.s,%.o,$(patsubst %.c,%.o,$(SRCS)))
OBJS4RM = $(subst /,\\,$(OBJS))
LIBS = ../../client/src/toolbox.a
.PHONY: clean
imageview.s37: $(OBJS) $(LIBS)
$(LD) $(LDFLAGS) --output-format s37 -o $@ $^
# Build the object files from C
%.o: %.c
$(CC) $(CFLAGS) -o $@ $^
# Build the object files from assembly
%.o: %.s
$(AS) $(ASFLAGS) -o $@ $^
# Clean up after a build
clean:
$(RM) $(OBJS4RM) *.s37 *.o *.a *.lst

View file

@ -0,0 +1,3 @@
# Sample: ImageView
This example demonstrates connecting to the Toolbox to read the directory on the SD card, look for BMP files, and display them on the bitmap. It compiles under the Calypsi C compiler for 65816 and uses some of its F256 support.

View file

@ -0,0 +1,19 @@
(define memories
'(
(memory LoMem
(address (#xa000 . #xcfff))
(type ANY))
(memory Vector (address (#xffe4 . #xffff)))
(memory Banks
(address (#x10000 . #x7ffff))
(type ANY)
(section (header #x10000)))
(memory DirectPage
(address (#x000100 . #x0001ff))
(section (registers ztiny)))
(block stack (size #x1000))
(block heap (size #x1000))
(base-address _DirectPageStart DirectPage 0)
(base-address _NearBaseAddress LoMem 0)
))

View file

@ -0,0 +1,10 @@
.extern __program_start
.section header
signature: .byte 0xf8, 0x16
version: .byte 0
start: .long __program_start
icon: .long 0
clut: .long 0
name: .asciz "imageview"

View file

@ -0,0 +1,49 @@
#include "../../client/src/include/toolbox.h"
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
t_file_info file_info;
void myprint(const char * text) {
int length = strlen(text);
sys_chan_write(0, (const uint8_t *)text, length);
}
int main(int c, char * argv[]) {
char line[80];
myprint("BMP ImageViewer for the Foenix F256\n");
short dir = sys_fsys_opendir("/sd0");
if (dir >= 0) {
bool keep_looping = true;
while (keep_looping) {
short result = sys_fsys_readdir(dir, &file_info);
if (result == 0) {
if (file_info.name[0] != 0) {
sprintf(line, "%s\n", file_info.name);
myprint(line);
} else {
keep_looping = false;
}
} else {
sprintf(line, "Could not read directory: %d\n", dir);
myprint(line);
keep_looping = false;
}
}
sys_fsys_closedir(dir);
} else {
sprintf(line, "Could not open directory: %d\n", dir);
myprint(line);
}
while (1) ;
}

View file

@ -0,0 +1,86 @@
#ifndef __MACROS_H
#define __MACROS_H
#ifdef __CALYPSI_ASSEMBLER__
#ifdef __CALYPSI_CODE_MODEL_SMALL__
#define libcode code
call .macro dest
jsr \dest
.endm
return .macro
rts
.endm
jump .macro dest
jmp \dest
.endm
#elif defined(__CALYPSI_CODE_MODEL_COMPACT__)
#define libcode compactcode
call .macro dest
jsr .kbank \dest
.endm
return .macro
rts
.endm
jump .macro dest
jmp .kbank \dest
.endm
#else
#define libcode farcode
call .macro dest
jsl \dest
.endm
return .macro
rtl
.endm
jump .macro dest
jmp long:\dest
.endm
#endif // __CALYPSI_CODE_MODEL_SMALL__
// ----------------------------------------------------------------------
//
// Define code and data model used. This is to add a bit of safety in
// case the way a file is assembled is combined with the wrong run-time.
//
// ----------------------------------------------------------------------
#if defined(__CALYPSI_DATA_MODEL_SMALL__)
.rtmodel dataModel,"small"
#elif defined (__CALYPSI_DATA_MODEL_MEDIUM__)
.rtmodel dataModel,"medium"
#elif defined(__CALYPSI_DATA_MODEL_LARGE__)
.rtmodel dataModel,"large"
#elif defined(__CALYPSI_DATA_MODEL_HUGE__)
.rtmodel dataModel,"huge"
#else
#pragma GCC error "unexpected data model"
#endif
#if defined(__CALYPSI_CODE_MODEL_SMALL__)
.rtmodel codeModel,"small"
#elif defined(__CALYPSI_CODE_MODEL_COMPACT__)
.rtmodel codeModel,"compact"
#elif defined(__CALYPSI_CODE_MODEL_LARGE__)
.rtmodel codeModel,"large"
#else
#pragma GCC error "unexpected code model"
#endif
#endif // __CALYPSI_ASSEMBLER__
#endif // __MACROS_H

View file

@ -310,6 +310,22 @@ void boot_from(enum boot_src_e device, boot_record_p boot_record) {
}
break;
case BOOT_SRC_SD1:
if (fsys_stat("/sd1/fnxboot.pgz", &file_info) >= 0) {
printf("Booting: /sd1/fnxboot.pgz\n");
boot_reset_screen();
proc_run("/sd0/fnxboot.pgz", 0, boot_args);
} else if (fsys_stat("/sd1/fnxboot.pgx", &file_info) >= 0) {
printf("Booting: /sd1/fnxboot.pgx\n");
boot_reset_screen();
result = proc_run("/sd1/fnxboot.pgx", 0, boot_args);
if (result != 0) {
printf("proc_run error: %d\n", result);
}
}
break;
case BOOT_SRC_CARTRIDGE:
case BOOT_SRC_ROM:
case BOOT_SRC_RAM:
@ -399,6 +415,7 @@ void boot_screen() {
}
boot_chain[i++] = BOOT_SRC_CARTRIDGE;
boot_chain[i++] = BOOT_SRC_SD0;
boot_chain[i++] = BOOT_SRC_SD1;
boot_chain[i++] = BOOT_SRC_ROM;
boot_src_cnt += 3;

View file

@ -47,6 +47,7 @@
#define CMD58 (58) /* READ_OCR */
static t_sd_card_info sd0_card_info;
static t_sd_card_info sd1_card_info;
/**
* @brief Transmit Busy Flag Check
@ -552,10 +553,14 @@ short sdc_install() {
// int_register(INT_SDC_INS, sdc_handler);
// int_enable(INT_SDC_INS);
sd0_card_info.reg = SD1_REG;
sd0_card_info.reg = SD0_REG;
sd0_card_info.status = 0;
sd0_card_info.type = 0;
sd1_card_info.reg = SD1_REG;
sd1_card_info.status = 0;
sd1_card_info.type = 0;
dev.number = BDEV_SD0;
dev.name = "SD0";
dev.data = &sd0_card_info;
@ -566,5 +571,14 @@ short sdc_install() {
dev.status = sdc_status;
dev.ioctrl = sdc_ioctrl;
return bdev_register(&dev);
short result = bdev_register(&dev);
if (result == 0) {
dev.number = BDEV_SD1;
dev.name = "SD1";
dev.data = &sd1_card_info;
result = bdev_register(&dev);
}
return result;
}

View file

@ -166,7 +166,7 @@
/ Drive/Volume Configurations
/---------------------------------------------------------------------------*/
#define FF_VOLUMES 1
#define FF_VOLUMES 2
/* Number of volumes (logical drives) to be used. (1-10) */

View file

@ -20,10 +20,10 @@ typedef struct s_sdc_spi {
#define SDx_SLOW 0x02 // 1 = Slow 400Khz, 0 = 25Mhz
#define SDx_BUSY 0x80 // 1 = Busy
#define SD0_REG ((volatile __attribute__((far)) p_sdc_spi)0xf016a0)
#define SD1_REG ((volatile __attribute__((far)) p_sdc_spi)0xf01d80)
#define SD0_REG ((volatile __attribute__((far)) p_sdc_spi)0xf01d00)
#define SD1_REG ((volatile __attribute__((far)) p_sdc_spi)0xf01d20)
#define SD0_STAT (*(volatile __far uint8_t *)0xf016a0)
#define SD0_STAT (*(volatile __far uint8_t *)0xf01d00)
#define SD0_STAT_CD 0x40 // When 1 = No Card, 0 = Card is Present
#define SD0_STAT_WP 0x80 // When 0 = Writeable, 1 = Card is Protected

BIN
src/toolbox-20.bin Normal file

Binary file not shown.

BIN
src/toolbox-21.bin Normal file

Binary file not shown.

BIN
src/toolbox-22.bin Normal file

Binary file not shown.

BIN
src/toolbox-23.bin Normal file

Binary file not shown.

BIN
src/toolbox-24.bin Normal file

Binary file not shown.

BIN
src/toolbox-25.bin Normal file

Binary file not shown.

BIN
src/toolbox-26.bin Normal file

Binary file not shown.

BIN
src/toolbox-27.bin Normal file

Binary file not shown.

BIN
src/toolbox-28.bin Normal file

Binary file not shown.

BIN
src/toolbox-29.bin Normal file

Binary file not shown.

BIN
src/toolbox-2A.bin Normal file

Binary file not shown.

BIN
src/toolbox-2B.bin Normal file

Binary file not shown.

BIN
src/toolbox-2C.bin Normal file

Binary file not shown.

BIN
src/toolbox-2D.bin Normal file

Binary file not shown.

BIN
src/toolbox-2E.bin Normal file

Binary file not shown.

BIN
src/toolbox-2F.bin Normal file

Binary file not shown.

BIN
src/toolbox-30.bin Normal file

Binary file not shown.

BIN
src/toolbox-31.bin Normal file

Binary file not shown.

BIN
src/toolbox-3F.bin Normal file

Binary file not shown.

2182
src/toolbox.bin Normal file

File diff suppressed because one or more lines are too long

View file

@ -67,7 +67,7 @@
#include "rsrc/font/MSX_CP437_8x8.h"
#include "rsrc/bitmaps/splash_c256_u.h"
const char* VolumeStr[FF_VOLUMES] = { "sd0" };
const char* VolumeStr[FF_VOLUMES] = { "sd0", "sd1" };
extern unsigned long __memory_start;

View file

@ -7,6 +7,6 @@
#define VER_MAJOR 1
#define VER_MINOR 0
#define VER_BUILD 16
#define VER_BUILD 17
#endif