-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* created geos-cbm * Fixed bug in CmpString and CmpFString * removed wrongly added makefile * removed SamVlir.txt file. * added __attribute((leave)) to all inline asm statements * added __attribute__((leave)) to all inline asm statements * added __attribute__((leaf)) to all geos library functions * removed definition for uint8_t and uint16_t and bool types and included stdbool.h and stdint.h instead * added README.md * fixed small issues and added install for README.md * - fixed a bug in DrawPoint and DrawLine where between multiple asm statements some flags might got changed - removed __attribute__((leave)) from the functions * changed geos.h include from "geos.h" to <geos.h> * applied clang-format to all *.c and *.h files * added an option to change the overlay memory size on command line * massaged the code, reformatted it, remove 2 register outputs in inline assembly * removed inline and retain definition and used __attribute__((retain)) and __attribute__((inline)) explicit * added extern "C" for cxx compiiles, removed unnessecary definitions, used #rpagma once, made a macro SETOVERLAYSIZE for easy modification. * removed -linit-stack from clang.cfg as init-stack is included in geos_crt.a * fixed wrong size of RAM in k in README * changed back from #pragma once to #ifndef FILENAME_H schema * removed type tags from vlir.ld * changed vlir.ld so that --no-check-sections is not longer needed * moved NOCROSSREFS out of SECTION in vlir.ld, removed packed enum definitions (as they are default), removed definition for NULL (inlude stddef.h if needed) * - added geos-cbm to main Readme - used local labels in assembler code - massaged the source code as per recommendation * fixed a typo in README.md * fixed a typo in README.md * fixed a typo * removed commented out code --------- Co-authored-by: Dirk Schnorpfeil <dirk@localhost>
- Loading branch information
1 parent
5138223
commit c37e567
Showing
23 changed files
with
5,370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
add_executable(SamVlir.cvt SamVlirRes.c SamVlirFile.c SamVlirEdit.c SamVlirHdr.c) | ||
target_compile_options(SamVlir.cvt PRIVATE "-Os") | ||
install_example(SamVlir.cvt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/******************************************************************** | ||
* SamVlir.h | ||
* | ||
* This file contains global definitions for the llvm-mos GEOS VLIR | ||
* sample application. | ||
* | ||
********************************************************************/ | ||
|
||
#ifndef SAMVLIR_H | ||
#define SAMVLIR_H | ||
|
||
#define NUM_MODS 2 /* This application has 2 swap modules */ | ||
#define MOD_FILE 1 /* record number for file module */ | ||
#define MOD_EDIT 2 /* record number for edit module */ | ||
|
||
#define NUM_DA 7 /* Geos menu can list names of 7 desk accessories*/ | ||
|
||
/* Defines for main menu */ | ||
|
||
#define MM_COUNT 3 /* Number of main menu items */ | ||
#define MM_TOP 0 /* top scanline of menu */ | ||
#define MM_BOTTOM 14 /* bottom scanline of menu */ | ||
#define MM_LEFT 0 /* left pixel position of menu */ | ||
#define MM_RIGHT 72 /* right pixel position of menu */ | ||
|
||
/* top of all submenus */ | ||
#define SM_TOP (MM_BOTTOM + 1) | ||
|
||
/* defines for GEOS menu */ | ||
#define GM_COUNT \ | ||
1 /* no of items (assuming no desk accessories \ | ||
InitDA will adjust table) */ | ||
#define GM_LEFT 0 /* left x position */ | ||
#define GM_WIDTH 79 /* width in pixels */ | ||
|
||
/* defines for FILE menu */ | ||
|
||
#define FM_COUNT 2 /* number of items */ | ||
#define FM_LEFT 29 /* left x position */ | ||
#define FM_WIDTH 40 /* width in pixels */ | ||
|
||
/* defines for EDIT menu */ | ||
|
||
#define EM_COUNT 3 /* number of items */ | ||
#define EM_LEFT 49 /* left x position */ | ||
#define EM_WIDTH 40 /* width in pixels */ | ||
|
||
/* resident module exports */ | ||
extern char DAText[8][17]; | ||
|
||
/* File module exports */ | ||
extern __attribute__((noinline)) void RunDA(uint8_t da_index); | ||
extern __attribute__((noinline)) void DoClose(void); | ||
|
||
/* Edit module exports */ | ||
extern __attribute__((noinline)) void DoCut(void); | ||
extern __attribute__((noinline)) void DoCopy(void); | ||
extern __attribute__((noinline)) void DoPaste(void); | ||
extern __attribute__((noinline)) void DoIcon1(void); | ||
|
||
/* Import from linker definition file overlay start and size */ | ||
extern uint8_t __overlayaddr; | ||
extern uint8_t __overlaysize; | ||
#define OVERLAYADDR ((uint8_t *)&__overlayaddr) | ||
#define OVERLAYSIZE ((uint16_t)&__overlaysize) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/******************************************************************** | ||
* SamVlirEdit.c | ||
* | ||
* This file contains the Edit Module code for the llvm-mos GEOS VLIR | ||
* sample application. | ||
* | ||
********************************************************************/ | ||
|
||
#include <geos.h> | ||
|
||
#include "SamVlir.h" | ||
|
||
/* Through this pragma all functions and module data will be stored in VLIR 2 | ||
* record. */ | ||
|
||
#pragma clang section text = ".vlir02.text" data = ".vlir02.data" bss = \ | ||
".vlir02.bss" | ||
|
||
/* Dialog box to indicate that an event handler funnction was called. */ | ||
/* Parameter 2 of DB_NAME_SECT sets the vlir record 2 */ | ||
|
||
DB_NAME_SECT(dlg_edit, vlir02) | ||
DB_DEFPOS(1) | ||
DB_ICON(OK, DBI_X_0, DBI_Y_2) | ||
DB_VARSTR(DBI_X_0, DBI_Y_0, __r15) | ||
DB_END(dlg_edit) | ||
|
||
/* Define string constants as static variables. This way they will be stored | ||
* in the vlir record 2 and not in the main constant string pool. | ||
*/ | ||
|
||
char cut_msg[] = "cut handler called."; | ||
char copy_msg[] = "copy handler called."; | ||
char paste_msg[] = "paste handler called."; | ||
char icon1_msg[] = "icon handler called."; | ||
|
||
/******************************************************************** | ||
* This is a dummy event handler function. Customize this for your | ||
* own application. The noinline decorator guarantees that the | ||
* function is stored in the VLIR 2 record and that the optimier | ||
* will not inline the code in the main (VLIR 0) record. | ||
********************************************************************/ | ||
|
||
__attribute__((noinline)) void DoCut(void) { | ||
__r15 = (uint16_t)cut_msg; | ||
DoDlgBox(dlg_edit); | ||
} | ||
|
||
/******************************************************************** | ||
* This is a dummy event handler function. Customize this for your | ||
* own application. The noinline decorator guarantees that the | ||
* function is stored in the VLIR 2 record and that the optimier | ||
* will not inline the code in the main (VLIR 0) record. | ||
********************************************************************/ | ||
|
||
__attribute__((noinline)) void DoCopy(void) { | ||
__r15 = (uint16_t)copy_msg; | ||
DoDlgBox(dlg_edit); | ||
} | ||
|
||
/******************************************************************** | ||
* This is a dummy event handler function. Customize this for your | ||
* own application. The noinline decorator guarantees that the | ||
* function is stored in the VLIR 2 record and that the optimier | ||
* will not inline the code in the main (VLIR 0) record. | ||
********************************************************************/ | ||
|
||
__attribute__((noinline)) void DoPaste(void) { | ||
__r15 = (uint16_t)paste_msg; | ||
DoDlgBox(dlg_edit); | ||
} | ||
|
||
/******************************************************************** | ||
* This is a dummy event handler function. Customize this for your | ||
* own application. The noinline decorator guarantees that the | ||
* function is stored in the VLIR 2 record and that the optimier | ||
* will not inline the code in the main (VLIR 0) record. | ||
********************************************************************/ | ||
|
||
__attribute__((noinline)) void DoIcon1(void) { | ||
__r15 = (uint16_t)icon1_msg; | ||
DoDlgBox(dlg_edit); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/******************************************************************** | ||
* SamVlirFile.c | ||
* | ||
* This file contains the File Module code for the llvm-mos GEOS VLIR | ||
* sample application. | ||
* | ||
********************************************************************/ | ||
|
||
#include <geos.h> | ||
|
||
#include "SamVlir.h" | ||
|
||
/* Through this pragma all functions and module data will be stored in VLIR 1 | ||
* record. */ | ||
|
||
#pragma clang section text = ".vlir01.text" data = ".vlir01.data" bss = \ | ||
".vlir01.bss" | ||
|
||
/******************************************************************** | ||
* This function loads and runs a desk accessory. Note that the call | ||
* to GetFile to load the desk accessory causes the memory under the | ||
* desk accessory to be swapped out and control transfered to the desk | ||
* accessory. When the desk accessory is "turned off" by executing a | ||
* call to RstrAppl, control returns to the application (in this case | ||
* the deskTop) immediatly following the call to GetFile. | ||
* The noinline decorator tells the optimizer to keep the code in | ||
* VLIR 1 record and to not inline it into the main (VLIR 0) record. | ||
********************************************************************/ | ||
|
||
uint8_t spriteBuf[7 * 64]; | ||
|
||
__attribute__((noinline)) void RunDA(uint8_t da_index) { | ||
|
||
/* place code that will run before a desk accessory here */ | ||
|
||
/* close any open VLIR files */ | ||
|
||
/* copy sprite picture data (for 7 sprites) to a buffer */ | ||
MoveData(&sprpic[1], spriteBuf, sizeof(spriteBuf)); | ||
|
||
/* save sprites double-Y flag in case is changed by desk accessory */ | ||
uint8_t old_cpu_data = CPU_DATA; | ||
CPU_DATA = IO_IN; | ||
uint8_t old_moby2 = moby2; | ||
moby2 = 0; | ||
CPU_DATA = old_cpu_data; | ||
|
||
disk_err_t err = GetFile(DAText[da_index], 0b00000000, 0, 0, 0, 0); | ||
|
||
/* At this point GEOS saves | ||
* - pointers to menu and icon structures | ||
* - all sprite x, y, color and doubleX info | ||
* | ||
* desk accessory code must: | ||
* - set its own sprite pictures and doubleXY information | ||
* - set the desired screen colors (40-column mode only) | ||
* - not use 0x0200-0x03ff for variables, because some new | ||
* applications (geoFile, geoDebug) do | ||
* | ||
* when desk accessory has finished, GEOS restores: | ||
* - pointers to menu and icon structures | ||
* - all sprite x, y, color and doubleX info | ||
* - | ||
*/ | ||
|
||
/* restore sprite´s double-y flag in case it was changed by the desk accessory | ||
*/ | ||
old_cpu_data = CPU_DATA; | ||
CPU_DATA = IO_IN; | ||
moby2 = old_moby2; | ||
CPU_DATA = old_cpu_data; | ||
|
||
/* restore sprite picture data */ | ||
MoveData(spriteBuf, &sprpic[1], 7 * 64); | ||
|
||
/* since we did not have DA save our foreground screen, | ||
* must recover from background here */ | ||
FillRam((void *)COLOR_MATRIX, 25 * 40, screencolors); | ||
|
||
/* since we did not have DA save our foreground screen, | ||
* must recover from background here. */ | ||
RecoverRectangle(0, MM_BOTTOM + 1, 319, 199); | ||
|
||
if (err != 0) { | ||
/* handle disk errors here */ | ||
} | ||
|
||
/* code to run after desk accessory completion goes here */ | ||
|
||
/* re-open VLIR files here */ | ||
} | ||
|
||
/* define string on file level so that it is stored in VLIR record 1. */ | ||
|
||
char close_msg[] = "close handler called."; | ||
|
||
/* Dialog box to indicate that close handler function was called. */ | ||
|
||
DB_NAME_SECT(dlgClose, vlir01) | ||
DB_DEFPOS(1) | ||
DB_ICON(OK, DBI_X_0, DBI_Y_2) | ||
DB_TXTSTR(DBI_X_0, DBI_Y_0, close_msg) | ||
DB_END(dlgClose) | ||
|
||
__attribute__((noinline)) void DoClose(void) { DoDlgBox(dlgClose); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************** | ||
* SamVlir.h | ||
* | ||
* This file contains the header block definition for the llvm-mos | ||
* GEOS VLIR sample application. | ||
* | ||
********************************************************************/ | ||
|
||
#include <geos.h> | ||
|
||
#include "SamVlir.h" | ||
|
||
__attribute__((section(".info_block"))) | ||
__attribute__((retain)) | ||
file_header_t __std_file_header = { | ||
3, | ||
21, | ||
0x80 | 63, | ||
{ | ||
0b11111111, 0b11111111, 0b11111111, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b10000000, 0b00000000, 0b00000001, 0b10000000, 0b00000000, 0b00000001, | ||
0b11111111, 0b11111111, 0b11111111, | ||
}, | ||
0x80 | USR, | ||
APPLICATION, | ||
VLIR, | ||
0x0400, | ||
0x03ff, | ||
0x0400, | ||
"Sample VLIR V1.0\000\000\000", | ||
0, | ||
"Dirk Schnorpfeil", | ||
"", | ||
"", | ||
"This is the llvm-mos GEOS VLIR sample application"}; |
Oops, something went wrong.