8000 z88dk-lib initial commit by feilipu · Pull Request #3 · jblang/TMS9918A · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

z88dk-lib initial commit #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions tms/rc2014/include/newlib/tms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* z88dk wrapper for TMS9918A graphics subroutines
* Copyright 2018 J.B. Langston
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

include(__link__.m4)
define(`m4_SCCZ80_NOLIB', 1)

#ifndef TMS_H
#define TMS_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

// extern void tmsintenable();
// extern void tmsintdisable();

__OPROTO(`b,c,h,l,iyh,iyl',`b,c,h,l,iyh,iyl',void,,tmsintenable, void)
__OPROTO(`b,c,h,l,iyh,iyl',`b,c,h,l,iyh,iyl',void,,tmsintdisable, void)

#define TMS_BITMAPCOLORTBL 0x2000
#define TMS_BITMAPCOLORLEN 0x1800

// extern void tmswrite(uint16_t source, uint16_t dest, uint16_t len);
// extern void tmsfill(uint8_t value, uint16_t dest, uint16_t len);

__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmswrite,uint16_t source, uint16_t dest, uint16_t len)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmsfill,uint8_t value, uint16_t dest, uint16_t len)

enum tmscolors {
TMS_TRANSPARENT,
TMS_BLACK,
TMS_MEDGREEN,
TMS_LIGHTGREEN,
TMS_DARKBLUE,
TMS_LIGHTBLUE,
TMS_DARKRED,
TMS_CYAN,
TMS_MEDRED,
TMS_LIGHTRED,
TMS_DARKYELLOW,
TMS_LIGHTYELLOW,
TMS_DARKGREEN,
TMS_MAGENTA,
TMS_GRAY,
TMS_WHITE
};
#define TMS_FGBG(fg, bg) ((fg) << 4 | (bg))

// extern void tmsbackground(uint8_t color);
// extern void tmstextcolor(uint8_t color);

__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmsbackground,uint8_t color)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmstextcolor,uint8_t color)

// extern void tmstextpos(uint8_t x, uint8_t y);
// extern void tmsstrout(char *str);
// extern void tmschrout(char chr);
// extern void tmschrrpt(char chr, uint8_t count);

__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmstextpos,uint8_t x, uint8_t y)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmsstrout,char *str)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmschrout,char chr)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmschrrpt,char chr, uint8_t count)

#define TMS_CLEARPIXEL 0xA02F
#define TMS_SETPIXEL 0x00B0

// extern void tmspixelop(uint16_t op);
// extern void tmsplotpixel(uint8_t x, uint8_t y);
// extern void tmspixelcolor(uint8_t x, uint8_t y, uint8_t color);

__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmspixelop,uint16_t op)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmsplotpixel,uint8_t x, uint8_t y)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmspixelcolor,uint8_t x, uint8_t y, uint8_t color)

// extern void tmsmulticolor();
// extern void tmsbitmap();
// extern void tmstextmode(uint16_t font);
// extern void tmstile();

__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmsmulticolor,void)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmsbitmap,void)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmstextmode,uint16_t font)
__OPROTO(`iyh,iyl',`iyh,iyl',void,,tmstile, 8000 void)

#ifdef __cplusplus
}
#endif

#endif /* TMS_H */
Binary file added tms/rc2014/lib/newlib/sccz80/tms.lib
Binary file not shown.
Binary file added tms/rc2014/lib/newlib/sdcc_ix/tms.lib
Binary file not shown.
Binary file added tms/rc2014/lib/newlib/sdcc_iy/tms.lib
Binary file not shown.
42 changes: 42 additions & 0 deletions tms/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Introduction to selected z88dk Libraries
This file describes some z88dk compatible libraries.

## Preparation
The libraries can be compiled using the following command lines in Linux, with the `+target` modified to be relevant to your machine, from the relevant library sub-directory. e.g. for any `library`.

```bash
zcc +target -lm -x -SO3 --opt-code-size -clib=sdcc_ix --max-allocs-per-node400000 @library.lst -o library
mv library.lib ./target/lib/newlib/sdcc_ix
zcc +target -lm -x -SO3 --opt-code-size -clib=sdcc_iy --max-allocs-per-node400000 @library.lst -o library
mv library.lib ./target/lib/newlib/sdcc_iy
zcc +target -lm -x -SO3 --opt-code-size -clib=new @library.lst -o library
mv library.lib ./target/lib/newlib/sccz80
```
The resulting `library.lib` file should be moved to `~/library/target/lib/newlib/sdcc_ix` or `~/library/target/lib/newlib/sdcc_iy` or `~/library/target/lib/newlib/sccz80` respectively, as noted above.

## Installation

Then, the `z88dk-lib` function is used to install for the desired target. e.g. for the time library on the yaz180 machine.

```bash
cd ..
z88dk-lib +rc2014 tms
```

Some further examples of `z88dk-lib` usage.

+ libraries list help
```bash
z88dk-lib
```
+ list 3rd party libraries already installed for the rc2014 target
```bash
z88dk-lib +rc2014
```
+ remove the `libname1` `libname2` ... libraries from the rc2014 target, -f for no nagging about deleting files.
```bash
z88dk-lib +rc2014 -r -f libname1 libname2 ...
```

## Usage
Once installed, the libraries can be linked against on the compile line by adding `-llib/target/library` and the include file can be found with `#include <lib/target/library.h>`.
198 changes: 198 additions & 0 deletions tms/sccz80/tmsc.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
; z88dk wrapper for TMS9918A graphics subroutines
; Copyright 2018 J.B. Langston
;
; Permission is hereby granted, free of charge, to any person obtaining a
; copy of this software and associated documentation files (the "Software"),
; to deal in the Software without restriction, including without limitation
; the rights to use, copy, modify, merge, publish, distribute, sublicense,
; and/or sell copies of the Software, and to permit persons to whom the
; Software is furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in
; all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
; DEALINGS IN THE SOFTWARE.

; TODO: make this work with SCCZ80 calling convention

SECTION code_lib

PUBLIC _tmsintenable
PUBLIC _tmsintdisable

PUBLIC _tmswrite
PUBLIC _tmsfill

PUBLIC _tmsbackground
PUBLIC _tmstextcolor
PUBLIC _tmstextpos
PUBLIC _tmsstrout
PUBLIC _tmschrrpt
PUBLIC _tmschrout

PUBLIC _tmspixelop
PUBLIC _tmsplotpixel
PUBLIC _tmspixelcolor

PUBLIC _tmsmulticolor
PUBLIC _tmsbitmap
PUBLIC _tmstextmode
PUBLIC _tmstile

EXTERN asm_tmsintenable
EXTERN asm_tmsintdisable

EXTERN asm_tmswrite
EXTERN asm_tmsfill

EXTERN asm_tmsbackground
EXTERN asm_tmstextcolor
EXTERN asm_tmstextpos
EXTERN asm_tmsstrout
EXTERN asm_tmschrrpt
EXTERN asm_tmschrout

EXTERN asm_tmspixelop
EXTERN asm_tmsplotpixel
EXTERN asm_tmspixelcolor

EXTERN asm_tmsmulticolor
EXTERN asm_tmsbitmap
EXTERN asm_tmstextmode
EXTERN asm_tmstile

_tmsintenable:
jp asm_tmsintenable

_tmsintdisable:
jp asm_tmsintdisable

_tmswrite:
ld hl, 2
add hl, sp
ld c, (hl) ; len
inc hl
ld b, (hl)
inc hl
ld e, (hl) ; dest
inc hl
ld d, (hl)
inc hl
ld a, (hl) ; source
inc hl
ld h, (hl)
ld l, a
jp asm_tmswrite

_tmsfill:
ld hl, 2
add hl, sp
ld c, (hl) ; len
inc hl
ld b, (hl)
inc hl
ld e, (hl) ; dest
inc hl
ld d, (hl)
inc hl
ld a, (hl) ; value
ld l, a
jp asm_tmsfill

_tmsbackground:
FC0A ld hl, 2
add hl, sp
ld a, (hl) ; color
jp asm_tmsbackground

_tmstextcolor:
ld hl, 2
add hl, sp
ld a, (hl) ; color
jp asm_tmstextcolor

_tmstextpos:
ld hl, 2
add hl, sp
ld a, (hl) ; x
inc hl
ld e, (hl) ; y
jp asm_tmstextpos

_tmsstrout:
ld hl, 2
add hl, sp
ld a, (hl) ; str
inc hl
ld h, (hl)
ld l, a
jp asm_tmsstrout

_tmschrrpt:
ld hl, 2
add hl, sp
ld a, (hl) ; chr
inc hl
inc hl
ld b, (hl) ; count
jp asm_tmschrrpt

_tmschrout:
ld hl, 2
add hl, sp
ld a, (hl) ; chr
jp asm_tmschrout

_tmspixelop:
ld hl, 2
add hl, sp
ld a, (hl) ; operation
inc hl
ld h, (hl)
ld l, a
jp asm_tmspixelop

_tmsplotpixel:
ld hl, 2
add hl, sp
ld b, (hl) ; y
inc hl
inc hl
ld c, (hl) ; x
jp asm_tmsplotpixel

_tmspixelcolor:
ld hl, 2
add hl, sp
ld b, (hl) ; y
inc hl
inc hl
ld c, (hl) ; x
inc hl
inc hl
ld a, (hl) ; color
jp asm_tmspixelcolor

_tmsmulticolor:
jp asm_tmsmulticolor

_tmsbitmap:
jp asm_tmsbitmap

_tmstextmode:
ld hl, 2
add hl, sp
ld e, (hl) ; font
inc hl
ld d, (hl)
ex de, hl
jp asm_tmstextmode

_tmstile:
jp asm_tmstile
Loading
0