Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Xeda112358

Pages: [1] 2 3 ... 316
1
ASM / Re: Sine Approximation [Z80]
« on: February 03, 2022, 09:08:55 pm »
Necropost: this came up elsewhere and I made a python version if anybody is interested. I think it could be implemented really well with logic gates!
https://gist.github.com/Zeda/98aab98fd32a231b878772a435ffb306

Code: [Select]
#!/usr/bin/python3

# This is ported from:
#    https://www.omnimaga.org/asm-language/sine-approximation-(z80)/
# (Xeda112358  a.k.a.  Zeda  a.k.a.  ZedaZ80)
#

from math import sin

def sineb(x):
    """Approximates 128*sin(x*2*pi/256)"""

    a1 = int(x)
    a0 = a1 << 1
    a2 = a1 >> 1

    # iteration 1
    if a1 & 64:
        l = ~a0 & 127
    else:
        l =  a0 & 127

    # iteration 2
    if a1 & 32:
        l += ~a1 & 31
    else:
        l +=  a1 & 31

    # iteration 3
    if a1 & 16:
        l += ~a2 & 7
    else:
        l +=  a2 & 7

    # check if it needs to be negated
    if a1 & 128:
        return -l
    else:
        return l

# Plot a graph of the approximation vs the actual
for x in range(0, 256, 2):
    y = sineb(x)
    z = int(sin(x*3.1415926535/128)*128)

    # translate and scale for "graphing"
    y += 128
    z += 128
    y >>= 1
    z >>= 1

    # "graph"
    #    X - Approximation
    #    O - Actual
    #    8 - used when the graphs overlap
    if y == z:
        print(" "*y + "8")
    elif y > z:
        print(" "*z + "X" + " "*(y-z-1) + "O")
    else:
        print(" "*y + "O" + " "*(z-y-1) + "X")

2
Axe / Re: Looping Through an Array in Axe
« on: December 15, 2021, 08:13:45 am »
I'm thinking it might be an order-of-operations issue since Axe obeys parentheses, but is otherwise left-to-right instead of PEMDAS.

Instead of this:
Code: [Select]
      If (RoomX≥XMin and RoomX≤XMax) and (RoomY≥YMin and RoomY≤YMax)
        0→R
        GetRoomStart()
      End
      !If (RoomX≥XMin and RoomX≤XMax) and (RoomY≥YMin and RoomY≤YMax)
        R++
      End
Try:
Code: [Select]
      If (RoomX≥XMin) and (RoomX≤XMax) and (RoomY≥YMin) and (RoomY≤YMax)
        0→R
        GetRoomStart()
      Else
        R++
      End

3
Axe / Re: Axe Loops not Working as Expected
« on: December 09, 2021, 07:39:39 pm »
The code is difficult to follow, but it looks like you are mixing 0-indexing and 1-indexing.
You loop J from 1 to Rooms, but then you are checking if J>0 in the same loop (which is always true).

J+(J*((J>0)*4))-4→Y
Simplifies to:
J+(J*(1*4))-4→Y
J+(J*4)-4→Y
J*5-4→Y

Maybe there is something there?

4
That is amazing :0

5
TI Z80 / Re: Elimination RPG: Early Release Build!!
« on: November 25, 2021, 02:01:27 pm »
Could it be that I used WabbitSign?  Should I use something else to sign the app?
I haven't used wabbitsign in a long time and I'm not sure if that is the issue. I generally use spasm and I've got it configured to automatically sign apps.

I know Wabbitemu is very generous with loading apps (it bypasses the calc's security which is great for streamlining development, but it hides signing issues).

I'm not much help with this stuff these ays XD .__.

6
TI Z80 / Re: Elimination RPG: Early Release Build!!
« on: November 25, 2021, 07:58:34 am »
I cannot send the 8xk file to my 84+. I get an error saying the application file is broken and to redownload it again, and if it doesn't work, to contact TI for help. D:
Out of curiosity, can you send it to an emulator?

7
TI Z80 / Re: Alien Breed 5 Episode III: Impact
« on: November 13, 2021, 08:10:25 am »
Holy heck that looks so good :O

8
TI Z80 / Re: Elimination: An RPG inspired by Earthbound / Pokemon
« on: November 07, 2021, 06:35:35 am »
Oh yeah, that definitely works :0

9
TI Z80 / Re: Elimination: An RPG inspired by Earthbound / Pokemon
« on: October 23, 2021, 04:03:12 pm »
Awww yiss, that looks pretty cool!
I definitely like the monochrome graphics (I also find that grayscale is just too rough to look at on actual hardware and with moving images).

10
ASM / Re: eZ80 Optimized Routines
« on: October 11, 2021, 12:32:17 pm »
Oh, fantastic! Good catch!

11
Other Calculators / Re: Darkblasters: A new graphical TI-84+/SE BASIC RPG
« on: September 11, 2021, 12:16:59 pm »
That is absolutely amazing, and especially for having been done in TI-BASIC  :o

12
Other Discussions / Re: Omnimaga turns 20 years old!
« on: September 02, 2021, 06:49:34 am »
Woah, happy birthday Omni!
!peanuts

13
Axe / Re: Looping Through an Array in Axe
« on: June 25, 2021, 04:57:29 pm »
If M  is less than 192, then M-192 will wrap back around to be >=65344.

Is that possibly the issue ? If so, and if Z is small enough, then you can probably change it to compare M with Z+128 instead.

14
ASM / Re: ASM Optimized routines
« on: June 18, 2021, 06:35:59 pm »
Wow, that's really neat. I don't have a use for that at the moment but I bet I can find one in some old, slow code.

How did you go about making the routine generator? I assume there are some simple rules it follows.
It looks through all the numbers 1-65535 to find some good code.
If the number is even, it essentially uses the code for n/2, but with an `add hl,hl` tacked on to the end. Otherwise it is odd and it first tries a shift-and-add algorithm (basically the classic, generic multiplication, but unrolled and with branches removed as we know which path it takes in advance). It registers whatever code it came up with, then it checks if it is faster or smaller to multiply by the factors (for example, it is faster to multiply by 27 by doing *3*9 or *9*3), so it finds all of the factors and checks for anything more efficient.

There are other tricks, too, like checking if it is faster to "negate" (i.e., *65535 is the same as *-1), and if there is a *(2^k-1) with k>3, it uses a subtraction. And it collapse things like 8 `add hl,hl` into `ld h,l \ ld l,0`, and has some pre-populated routines in the table.

It doesn't really know anything about the instruction set, so it can't do any fancy optimizations :(

15
ASM / Re: ASM Optimized routines
« on: June 18, 2021, 05:19:34 pm »
I wrote a program to generate 16-bit multiplication-by-constant routines. It isn't perfect, but it probably produced optimal code for a lot of them!

The attached tar.xz file has the (undocumented) program and a 28.8MB file of routines :P

For example, it has these two routines for mul_hl_1337:
Code: [Select]
mul_hl_1337:  ; size optimized
;17 bytes, 173cc
  ld b,h
  ld c,l
  add hl,hl
  add hl,hl
  add hl,bc
  add hl,hl
  add hl,hl
  add hl,hl
  add hl,bc
  add hl,hl
  add hl,bc
  add hl,hl
  add hl,bc
  add hl,hl
  add hl,hl
  add hl,hl
  add hl,bc

Code: [Select]
mul_hl_1337:  ; speed optimized
;25 bytes, 148cc
  ld b,h
  ld c,l
  add hl,hl
  add hl,bc
  add hl,hl
  add hl,bc
  ld b,h
  ld c,l
  add hl,hl
  add hl,bc
  ld a,h
  ld h,l
  rra
  rr h
  rra
  rr h
  rra
  and 11000000b
  ld l,a
  or a
  sbc hl,bc

Pages: [1] 2 3 ... 316