Search found 74 matches

by derekfountain
Sun Nov 28, 2021 11:43 am
Forum: Sinclair ZX
Topic: SDCC __preserves_regs broken?
Replies: 2
Views: 59

Re: SDCC __preserves_regs broken?

Right, so last night I was a bit hasty blaming SDCC for this one. :rolleyes: The underlying code is commented: asm_zx_pxy2saddr: ; enter : l = x coordinate ; h = valid y coordinate ; ; exit : hl = screen address of byte containing pixel ; e = x coordinate ; d = y coordinate ; ; uses : af, de, hl so ...
by derekfountain
Sat Nov 27, 2021 9:26 pm
Forum: Sinclair ZX
Topic: SDCC __preserves_regs broken?
Replies: 2
Views: 59

SDCC __preserves_regs broken?

Something seems broken in recent SDCC. Maybe. I'm not quite sure what's going on... The testcase is this: #include <arch/zx.h> int main(void) { uint16_t x; uint8_t y; for( y=0; y<192; y++ ) { for( x=0; x<256; x++ ) { uint8_t *test = zx_pxy2saddr( x, y ); *test = 255; } } return 0; } zcc +zx -vn -cli...
by derekfountain
Fri Nov 26, 2021 4:02 pm
Forum: Sinclair ZX
Topic: math16 on the Spectrum
Replies: 15
Views: 209

Re: math16 on the Spectrum

sdcc doesn't appear to have #undefine. I hacked the header file: extern half_t hypotf16(half_t x,half_t y); extern half_t hypotf16_callee(half_t x,half_t y) __z88dk_callee; #define hypotf16DISABLED(a,b) hypotf16_callee(a,b) which I think will do what you mean? The test case now finds other, more int...
by derekfountain
Fri Nov 26, 2021 2:21 pm
Forum: Sinclair ZX
Topic: math16 on the Spectrum
Replies: 15
Views: 209

Re: math16 on the Spectrum

OK, how about this one: #pragma printf %f #pragma scanf %f #include <stdio.h> #include <math.h> #define COUNT 500 half_t results[COUNT]; int i; int main(void) { half_t s1; half_t s2; half_t hy; s1=f16_u32(4); s2=f16_u32(5); hy=hypotf16( s1, s2 ); printf("s1 = %f\ns2 = %f\nhy = %f\n\n",f32_...
by derekfountain
Fri Nov 26, 2021 12:31 pm
Forum: Sinclair ZX
Topic: math16 on the Spectrum
Replies: 15
Views: 209

Re: math16 on the Spectrum

The range of a half-precision float is limited, so I think you're going out of range. It looks like the converters don't seem to have bounds checking for performance reasons. There's some background on this datatype here: https://en.wikipedia.org/wiki/Half-precision_floating-point_format Ah right. ...
by derekfountain
Fri Nov 26, 2021 11:10 am
Forum: Sinclair ZX
Topic: math16 on the Spectrum
Replies: 15
Views: 209

Re: math16 on the Spectrum

OK, I picked up nightly and confirmed the fix is working. :) But just to confirm I still don't know what I'm doing, I added a zero to my testcase: #pragma printf %f #include <stdint.h> #include <stdio.h> #include <math.h> int main(void) { half_t t1 = f16_i32(10000); half_t t2 = f16_u32(100000); prin...
by derekfountain
Thu Nov 25, 2021 10:22 pm
Forum: Sinclair ZX
Topic: math16 on the Spectrum
Replies: 15
Views: 209

Re: math16 on the Spectrum

Thanks dom. I'll be returning to this math16 stuff over the weekend. I might be bothering you some more. :)
by derekfountain
Thu Nov 25, 2021 11:03 am
Forum: Sinclair ZX
Topic: math16 on the Spectrum
Replies: 15
Views: 209

Re: math16 on the Spectrum

I'm still floundering about, and I've got as far as this: #pragma printf %f #include <stdint.h> #include <stdio.h> #include <math.h> int main(void) { half_t t1 = f16_i32(10000); half_t t2 = f16_u32(10000); printf("t1 = %f\nt2 = %f\n",f32_f16(t1),f32_f16(t2)); return 0; } which results in t...
by derekfountain
Wed Nov 24, 2021 10:17 pm
Forum: Sinclair ZX
Topic: math16 on the Spectrum
Replies: 15
Views: 209

Re: math16 on the Spectrum

dom wrote: Wed Nov 24, 2021 9:41 pm With that knowledge, it's fairly obvious where (rounding errors aside) your printf values are coming from.
I assure you it isn't! I really don't understand what's going on inside printf or the math16 library.
by derekfountain
Wed Nov 24, 2021 7:59 pm
Forum: Sinclair ZX
Topic: math16 on the Spectrum
Replies: 15
Views: 209

math16 on the Spectrum

I'm trying to get the basics of math16 working on the Spectrum. Cobbling together information from round the 'net, my code is: #pragma printf %f #include <stdio.h> #include <math.h> #ifdef __MATH_MATH16 #define DOUBLE half_t #else #define DOUBLE float #endif int main(void) { DOUBLE t1 = (DOUBLE)1000...
by derekfountain
Fri Oct 08, 2021 10:31 am
Forum: MSX, SVI, TMS99x8 and Sega Master System
Topic: Arkos Tracker 2 in z88dk
Replies: 11
Views: 1265

Re: Arkos Tracker 2 in z88dk

I have one of the demo AT2 tunes working from a z88dk C program. I used rasm and the binary blob method, so not the ideal approach.

I've put a (Linux) project here:

https://github.com/derekfountain/z88dk- ... r2-example

if it's of any use to anyone.
by derekfountain
Mon Sep 13, 2021 8:40 pm
Forum: Sinclair ZX
Topic: Source level debugger
Replies: 6
Views: 1549

Re: Source level debugger

I believe he's been having trouble getting in contact with any of the fuse maintainers so the PR was closed by himself. I pulled his Fuse tree for a look, but it was based off an older version of Fuse and was MacOS only. It didn't build on Linux, so it was hardly surprising there wasn't much intere...
by derekfountain
Thu Sep 02, 2021 3:03 pm
Forum: Other targets
Topic: Comparing a Char Z88
Replies: 5
Views: 848

Re: Comparing a Char Z88

strcmp() compares two strings, you're trying to use it to compare two characters. Since characters are simple 8-bit integer values in C you can compare them directly: if( Hands[i] == 'q' ) ... Also, C uses == for comparison and single = for assignment, so if (test = 0) should be if (test == 0) if it...
by derekfountain
Tue Aug 24, 2021 1:04 pm
Forum: Sinclair ZX
Topic: how pass a #define from c to asm? - newbie question
Replies: 12
Views: 1477

Re: how pass a #define from c to asm? - newbie question

The request, as I understood it, wasn't to pass a variable from C to ASM, but to pass a compile time constant from C to ASM.
by derekfountain
Tue Aug 24, 2021 9:26 am
Forum: Sinclair ZX
Topic: how pass a #define from c to asm? - newbie question
Replies: 12
Views: 1477

Re: how pass a #define from c to asm? - newbie question

#define creates a C preprocessor macro definition, and passing such a thing to the assembler doesn't make a lot of sense. That said, I did spent quite a while trying to find a way to share a simple numerical value between C and ASM files. There might be a way to do it with pragmas: https://www.z88dk...
by derekfountain
Mon Jul 26, 2021 10:31 am
Forum: Misc
Topic: What are calls to l_gint and l_pint for?
Replies: 9
Views: 1619

Re: What are calls to l_gint and l_pint for?

Also, just a note about using --c-code-in-asm very carefully. It does change the code execution flow substantially. I've spent quite a few nights chasing down phantom issues because of this. For example, it will remove callee and fastcall optimisation to functions that provide it, which also change...
by derekfountain
Tue Jun 22, 2021 10:34 am
Forum: Sinclair ZX
Topic: Tight memory map with IM2 table
Replies: 11
Views: 1756

Re: Tight memory map with IM2 table

Quite right, but surely it should be flagged with an error rather than generating clearly incorrect code?

The example works if the wpoke() call gets the correct value.
by derekfountain
Tue Jun 22, 2021 10:03 am
Forum: Sinclair ZX
Topic: Tight memory map with IM2 table
Replies: 11
Views: 1756

Re: Tight memory map with IM2 table

This is interesting: // zcc +zx -vn -compiler=sdcc -clib=sdcc_iy main.c -o main.bin -startup=1 -create-app --list --c-code-in-asm #include <stdio.h> void main() { void *val1 = ( (void*)0xf5f5 ); void *val2 = val1 + 1; printf("Val2 is %p\n", val2); } On a Spectrum that prints "Val2 is ...
by derekfountain
Mon May 10, 2021 8:42 am
Forum: Project Activity
Topic: [changes] 08/05/2021
Replies: 2
Views: 1048

Re: [changes] 08/05/2021

Looking at these updates, and the previous ones, I'm seeing lots of activity in the classic library, but virtually nothing in newlib. Assuming I'm reading it right, is that deliberate? What's the development status with newlib?
by derekfountain
Fri Apr 30, 2021 11:45 am
Forum: Sinclair ZX
Topic: SP1 - Animation of background tiles: intriguing sentence...
Replies: 11
Views: 1882

Re: SP1 - Animation of background tiles: intriguing sentence...

AA moved on to the Next and doesn't post here any more, which is a shame given how much of it he wrote and how much he knows. We have to manage without him. :) There's a rather complicated looking example in the standard distribution: z88dk/libsrc/sprites/software/sp1/spectrum/examples/ex6b.c which ...
by derekfountain
Mon Apr 19, 2021 8:08 am
Forum: Sinclair ZX
Topic: address of a specific method
Replies: 2
Views: 869

Re: address of a specific method

Code: Select all

methodAdr= &my_method();
would run my_method() and give you the address of the result. I think, I'm not sure I've ever seen C code like that. :)

Code: Select all

methodAdr=my_method;
is what you're after.
by derekfountain
Thu Mar 25, 2021 3:23 pm
Forum: Sinclair ZX
Topic: Isometric games with SP1
Replies: 4
Views: 1265

Re: Isometric games with SP1

I've never seen an isometric game done with SP1. It might work. :) I know that just drawing onto the screen then displaying masked sprites doesn't work. SP1 needs to know about the screen so it can optimise its masking, which is why SP1 tiles are used for backgrounds. But there's a discussion here: ...
by derekfountain
Fri Mar 19, 2021 5:35 pm
Forum: Sinclair ZX
Topic: [HOWTO] Setting colours on sp1 sprites
Replies: 3
Views: 992

Re: [HOWTO] Setting colours on sp1 sprites

I've not seen that alternative approach you link to, so I spent some time experimenting with it. Example code for anyone interested:

https://github.com/derekfountain/z88dk- ... r_faster.c
by derekfountain
Fri Mar 19, 2021 9:12 am
Forum: Sinclair ZX
Topic: [HOWTO] Setting colours on sp1 sprites
Replies: 3
Views: 992

Re: [HOWTO] Setting colours on sp1 sprites

Ah yes, that broken interface where you have to pass the iterator function its parameters via global variables. :D If I may be so bold, and for those who might end up here via a search, I'll plug my getting started tutorial which covers this point: https://github.com/z88dk/z88dk/blob/master/doc/ZXSp...
by derekfountain
Sun Feb 14, 2021 10:01 am
Forum: Misc
Topic: Accessing https://z88dk.org
Replies: 17
Views: 3104

Re: Accessing https://z88dk.org

It's perfect, everything it needs to be. :)