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 ... 44 45 [46] 47 48 ... 317
676
Other Calc-Related Projects and Ideas / Re: Open Sprite Library
« on: November 15, 2013, 12:04:51 pm »
I am still getting the error, on each page. The rest says, "Your browser sent a request that this server could not understand."

677
Other Calc-Related Projects and Ideas / Re: Open Sprite Library
« on: November 15, 2013, 11:32:46 am »
I keep getting "400 Bad Request" :/

678
ASM / Re: ASM Optimized routines
« on: November 14, 2013, 11:50:30 pm »
If you are willing to use a 256-byte LUT, then lg() can be computed in an average of 340 t-states, and for an additional 325 (at most), ln() can be computed from that:
(these are fixed point 8.8 routines)
Code: [Select]
ln_88:
;Input: HL is a fixed point number
;Output: ln(H.L)->H.L
;Speed: Avg: 340+(325 worst case)
call lg_88
;now signed multiply HL by 355, then divide by 2 (rounding)
    ld de,0
    bit 7,h
    jr z,$+9
    dec e \ xor a \ sub l \ ld l,a
    sbc a,a \ sub h \ ld h,a
    ld b,h
    ld c,l
    xor a
add hl,hl
    add hl,hl \ rla
add hl,bc \ adc a,d
add hl,hl \ rla
add hl,bc \ adc a,d
add hl,hl \ rla
add hl,hl \ rla
add hl,hl \ rla
add hl,hl \ rla
add hl,bc \ adc a,d
add hl,hl \ rla
add hl,bc \ adc a,d
    sra a \ rr h
    ld l,h
    ld h,a
    inc e
    ret nz
    xor a \ sub l \ ld l,a
    sbc a,a \ sub h \ ld h,a
    ret
lg_88:
;Input: HL is a fixed point number
;Output: lg(H.L)->H.L
;Speed: Avg: 340
ld de,lgLUT
ld b,0
ld a,h
or a
ret m
ld a,l
jr z,$+8
inc b \ srl h \ rra \ jr nz,$-4
or a \ jr nz,$+6
ld hl,8000h \ ret
rra \ inc b \ jr nc,$-2
;A is the element to look up in the LUT
ld l,a
    ld c,h
    dec b
add hl,hl
add hl,de
ld e,(hl)
inc hl
ld d,(hl)
    ex de,hl
add hl,bc
ret
lglut:
.dw $F800
.dw $F996
.dw $FA52
.dw $FACF
.dw $FB2C
.dw $FB76
.dw $FBB3
.dw $FBE8
.dw $FC16
.dw $FC3F
.dw $FC64
.dw $FC86
.dw $FCA5
.dw $FCC1
.dw $FCDC
.dw $FCF4
.dw $FD0B
.dw $FD21
.dw $FD36
.dw $FD49
.dw $FD5C
.dw $FD6D
.dw $FD7E
.dw $FD8E
.dw $FD9D
.dw $FDAC
.dw $FDBA
.dw $FDC8
.dw $FDD5
.dw $FDE2
.dw $FDEE
.dw $FDFA
.dw $FE06
.dw $FE11
.dw $FE1C
.dw $FE26
.dw $FE31
.dw $FE3B
.dw $FE44
.dw $FE4E
.dw $FE57
.dw $FE60
.dw $FE69
.dw $FE71
.dw $FE7A
.dw $FE82
.dw $FE8A
.dw $FE92
.dw $FE9A
.dw $FEA1
.dw $FEA9
.dw $FEB0
.dw $FEB7
.dw $FEBE
.dw $FEC5
.dw $FECB
.dw $FED2
.dw $FED8
.dw $FEDF
.dw $FEE5
.dw $FEEB
.dw $FEF1
.dw $FEF7
.dw $FEFD
.dw $FF03
.dw $FF09
.dw $FF0E
.dw $FF14
.dw $FF19
.dw $FF1E
.dw $FF24
.dw $FF29
.dw $FF2E
.dw $FF33
.dw $FF38
.dw $FF3D
.dw $FF42
.dw $FF47
.dw $FF4B
.dw $FF50
.dw $FF55
.dw $FF59
.dw $FF5E
.dw $FF62
.dw $FF67
.dw $FF6B
.dw $FF6F
.dw $FF74
.dw $FF78
.dw $FF7C
.dw $FF80
.dw $FF84
.dw $FF88
.dw $FF8C
.dw $FF90
.dw $FF94
.dw $FF98
.dw $FF9B
.dw $FF9F
.dw $FFA3
.dw $FFA7
.dw $FFAA
.dw $FFAE
.dw $FFB2
.dw $FFB5
.dw $FFB9
.dw $FFBC
.dw $FFC0
.dw $FFC3
.dw $FFC6
.dw $FFCA
.dw $FFCD
.dw $FFD0
.dw $FFD4
.dw $FFD7
.dw $FFDA
.dw $FFDD
.dw $FFE0
.dw $FFE4
.dw $FFE7
.dw $FFEA
.dw $FFED
.dw $FFF0
.dw $FFF3
.dw $FFF6
.dw $FFF9
.dw $FFFC
.dw $FFFF

679
ASM / Re: ASM Optimized routines
« on: November 14, 2013, 08:17:22 pm »
This version works on (0,128) and averages less than 1250 t-states:
Code: [Select]
lognat:
;Input:  H.L needs to be on (0,128.0)
;Output: H.L if c flag set
; returns nc if input is negative (HL not modified)
;Error:
; The error on the outputs is as follows:
; 20592 inputs are exact
; 12075 inputs are off by 1/256
; 100 inputs are off by 2/256
; So all 32767 inputs are within 2/256, with average error being <1/683 which is smaller than 1/256.
;Size: 177 bytes
;Speed: average speed is less than 1250 t-states

ld a,h \ or l \ jr nz,$+5
ld h,80h \ ret
dec h
dec h
jr nz,$+9
inc l \ dec l
jr nz,normalizeln-1
ld l,177
ret
inc h
jr nz,normalizeln
ld b,h
ld c,l
ld e,l
ld d,8
add hl,hl
add hl,hl
add hl,de
ex de,hl
call HL_Div_DE
ld h,a \ ld l,b
sla h \ jr c,$+3 \ ld l,c
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
rl l
ld a,h
adc a,b
ld h,b
ld l,a
scf
ret
HL_Div_DE:
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ adc a,a \ ret

inc h
normalizeln:
xor a
inc h \ ret m
ld d,a \ ld e,a
ld a,l
jr z,toosmall
inc e \ srl h \ rra \ jr nz,$-4
rla \ rl h
dec e
stepin:
ld l,a
push de
call lognat
pop de
;now multiply DE by 355, then divide by 2 (rounding)
ld b,d \ ld c,e \ ld a,d
ex de,hl
add hl,hl
add hl,hl ;4
add hl,bc ;5
add hl,hl ;10
add hl,bc ;11
add hl,hl ;22
add hl,hl
add hl,hl
add hl,hl
add hl,bc
add hl,hl
add hl,bc
sra h \ rr l
adc hl,de
scf
ret
toosmall:
dec d
dec e \ add a,a \ jr nc,$-2
inc h
jp stepin
The worst error is 2/256, which is much better than I thought it would be :) On [1,2] it is at worst 1/256 and the average case is <1/683 which is smaller than 1/256 (the smallest positive 8.8 number).

680
ASM / Re: ASM Optimized routines
« on: November 13, 2013, 03:09:47 pm »
I made this rather fast 8.8 fixed point natural log (ln, loge) routine today based on some math I have been working on. It currently averages 677 t-states, but only works on [1,2] I plan to extend this to the whole range of numbers by using a 5 element LUT and a single division making the average somewhere around 1100 t-states:
Code: [Select]
lognat:
;Input:  H.L needs to be on [1,2]
;Output: H.L if z flag is set, else if nz, no result
;avg speed: 677 t-states
dec h
    dec h
jr nz,$+8
inc l \ dec l
ret nz
ld l,177
ret
inc h
ret nz
ld b,h
ld c,l
ld e,l
ld d,8
add hl,hl
add hl,hl
add hl,de
ex de,hl

add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ jr nc,$+3 \ add hl,de \ adc a,a
add hl,hl \ sbc hl,de \ adc a,a

ld h,a \ ld l,b
sla h \ jr c,$+3 \ ld l,c
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
add hl,hl \ jr c,$+3 \ add hl,bc
rl l
ld a,h
adc a,b
ld l,a
ld h,b
cp a
ret
I had fun twisting some of the logic, but there is a division and multiplication in there. It might seem backwards, but it was optimal :)

681
TI Z80 / Re: Shutdown (a clone of Lights Out Deluxe)
« on: November 11, 2013, 01:15:16 pm »
I like labels in BASIC because they can often be an excellent solution and often the best solution ;)
[...]
When's that ??? They also have that memory bug
That memory 'bug' isn't a bug, actually, it is just misuse of Goto and Lbl inside While, Repeat, and For loops.

Examples are when you use the Menu() command, the options need to jump to labels, then if you want to jump back to the menu, you either need to use a non-optimal Repeat loop, or the more optimal Goto. For example:
Code: [Select]
Lbl 0
Menu("HEADER","ITEM 1",01,"ITEM 2",10,"EXIT",1
Lbl 01
Pause "HI!
Goto 0
Lbl 10
Pause "HAHAHAHAHA
Goto 0
Lbl 1

In reality, While loops and Repeat loops use memory (so large nestings of these can consume lots of RAM) whereas Lbl and Goto use no memory. In RPGs, using labels is usually the best option, and for games where you want to use subroutines without using subprograms, you can take advantage of mixing labels and while loops. I made heavy use of this in an RPG a while ago.

To be more technical, the OS needs to push information onto an operator stack whenever it executes a loop. When it reaches an End, it uses that information and it doesn't remove it until the loop is finished. If you had 9 nested while loops, then , it pushes the data for each loop onto this stack, and when it reaches an End, the information is popped off in reverse order. If you use a Goto to jump out of a loop, the data never gets popped off the stack unless you place an unused end somewhere (but then only one item is popped off).

682
TI Z80 / Re: Shutdown (a clone of Lights Out Deluxe)
« on: November 11, 2013, 12:56:18 pm »
I like labels in BASIC because they can often be an excellent solution and often the best solution ;)

Anyways, to answer harold, there are no unsolvable starting conditions. (Think of it like a scrambled Rubiks cube, or a scrambled knot in a string whose ends are tied together). When I made one, I wasn't sure if there were unsolvable solutions, so I just simulated n steps and presented the board.

EDIT: Oops, it seems there are some unsolvable boards for some sizes.

683
Wow, these are fantastic o.o I definitely missed a lot of these.

684
HP Calculators / Re: 16 FPS 3D graphics on HP Prime! (sort-of)
« on: November 10, 2013, 09:06:46 am »
That is fantastic O.O Wow. :thumbsup:

685
TI Z80 / Re: [contest '13][asm] Digger
« on: November 10, 2013, 08:16:22 am »
For path finding, I have only successfully done it on a tiled maze. Essentially, I had the human player and the non human player 'chasing.' Chasing is done by moving in the optimal direction to be closer to the human player. The trick is when the chaser gets stuck, I would draw on some other buffer marking the position and the chaser would not be able to stay on that tile, so they would move backwards or left/right and each tile visited for the next 8 or 16 turns would be marked as well and they would remain marked for 8 or 16 turns (think of a snake from a snake game being placed on the other buffer growing for 8 or 16 turns, then shrinking).

This allows the chaser a little more intelligence to get unstuck, and when you have multiple chasers, the others can avoid getting stuck, too, while potentially taking other routes. I actually got the idea from a cellular automata experiment where I had a few hundred cells navigating a maze and the majority of them were able to find the exit. That, however, is too taxing on the CPU for use in a game on these calculators.

I wish I still had a working example :/

686
Math and Science / Re: Estimating Functions
« on: November 10, 2013, 08:03:47 am »
Applying the same method to ln(1+x), there is a similar formula to that of atan that is also simple and requires one less multiplication and one less shift for 9 bits of accuracy on [1,2]

EDIT: See the first post for the function.

687
TI Z80 / Re: Projects Update, Zeda
« on: November 08, 2013, 02:51:50 pm »
I do not have an 8XU to test it, it is just a bunch of code. I want to write a simple command line interface first, as an App that clears RAM and uses nothing from the OS. Then if I can successfully use it as a calculator and make a simple program, I will try to turn it into an 8xu.

688
TI Z80 / Re: Projects Update, Zeda
« on: November 08, 2013, 12:22:03 pm »
@Matrefeytontias: GrammerOS has been planned since Grammer first started :) I have been working on parts of its code every so often and rewriting it for better ideas.

@DJ_Omnimaga: Yes, those types of loops get optimised to something much faster before execution. There is a command called 'Goto [lbl]If [condition]'. 'While ' is replaced by the GotoIf and the EndWhile is replaced by a Goto that jumps back to the GotoIf (making it faster and labels are all precomputed, meaning no stack overflow issues).
Repeat is like While, except the End gets replaced by a GotoIf, jumping back to the beginning of the block.

'If' gets replaced by a GotoIf not(condition) and jumps to the End (or the Else condition), et cetera.

For() gets replaced by an initialising condition, then the EndFor gets replaced by an increment code and a GotoIf. FOr example:
Code: [Select]
For(A,1,10,.1)
<<stuff>>
End
get replaced by:
Code: [Select]
1→A
lbl for1
<<stuff>>
A+.1→A
Goto for1 If A!=1
Since labels are all precomputed offsets, all of these Goto commands are really fast.

689
TI Z80 / Re: Projects Update, Zeda
« on: November 08, 2013, 08:38:58 am »
Oh, I should clarify. To use the same kind of math abilities, this should be about as fast as BASIC. Graphics and such should still be faster, and if the programmer uses integers or even 24-bit floats instead of full 80-bit floats, the program should run much faster than TI-BASIC.

690
Miscellaneous / Re: What is your avatar?
« on: November 07, 2013, 07:36:13 pm »
I am trying to use one of my fractals, but the server seems to be having difficulty. I'll try to post the image here and use the link for that :P

EDIT: 4000th post and fixed a typo.

Pages: 1 ... 44 45 [46] 47 48 ... 317