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 ... 43 44 [45] 46 47 ... 317
661
« on: December 02, 2013, 08:33:35 am »
For example, I played Donkey Kong (DK5ION) that saved highscores to an appvar. I unarchived it, opened Calcsys, figured out the format of the highscore list, and edited it.
Did you mean you cheated ?
* Hayleia runs
Yup I wanted to see what an appvar was, so I tried to mess with the data to see what would happen, and it worked (This was before I knew Assembly).
662
« on: December 01, 2013, 08:07:07 pm »
Appvars can be edited by any program you make, but you can store any kind of data to appvars. Appvars are just a a chunk of memory that you do whatever you want to. There is no inherent structure, so unless you know the format of the appvar, there is no way of knowing what each byte represents. If you do know the format, you can make an editor to edit the data. For example, I played Donkey Kong (DK5ION) that saved highscores to an appvar. I unarchived it, opened Calcsys, figured out the format of the highscore list, and edited it. I did the same with Graph3D, to edit the Z= equations.
663
« on: November 30, 2013, 01:48:25 pm »
* Xeda112358 should totally vote
664
« on: November 28, 2013, 08:45:11 am »
Here is a 32-bit square root routine. I am fairly sure there are optimisations that can be made, especially to the stuff I added last night. I already found a bunch of code that I removed, about 32 bytes, saving 128 t-states.
SqrtHLDE: ;input: HLDE ;Output: BC ;310 bytes ;Average is about 1443 t-states push de xor a ld b,a
ld e,l ld l,h ld h,a
add hl,hl add hl,hl cp h jr nc,$+5 dec h ld a,4
add hl,hl add hl,hl ld c,a sub h jr nc,$+6 cpl ld h,a inc c inc c
ld a,c add hl,hl add hl,hl add a,a ld c,a sub h jr nc,$+6 cpl ld h,a inc c inc c
ld a,c add hl,hl add hl,hl add a,a ld c,a sub h jr nc,$+6 cpl ld h,a inc c inc c
ld a,c ld l,e
add hl,hl add hl,hl add a,a ld c,a sub h jr nc,$+6 cpl ld h,a inc c inc c
ld a,c add hl,hl add hl,hl add a,a ld c,a sub h jr nc,$+6 cpl ld h,a inc c inc c
ld a,c add a,a \ ld c,a add hl,hl add hl,hl jr nc,$+6 sub h \ jp $+6 sub h jr nc,$+6 inc c \ inc c cpl ld h,a
ld a,l ld l,h add a,a ld h,a adc hl,hl adc hl,hl sll c \ rl b sbc hl,bc jr nc,$+3 add hl,bc sbc a,a \ add a,a \ inc a \ add a,c \ ld c,a
;iteration 9 ;now I need to rotate in more bits pop de sla d \ adc hl,hl \ sla d \ adc hl,hl sll c \ rl b sbc hl,bc jr nc,$+3 add hl,bc sbc a,a \ add a,a \ inc a \ add a,c \ ld c,a
sla d \ adc hl,hl \ sla d \ adc hl,hl sll c \ rl b sbc hl,bc jr nc,$+3 add hl,bc sbc a,a \ add a,a \ inc a \ add a,c \ ld c,a
sla d \ adc hl,hl \ sla d \ adc hl,hl sll c \ rl b sbc hl,bc jr nc,$+3 add hl,bc sbc a,a \ add a,a \ inc a \ add a,c \ ld c,a
sla d \ adc hl,hl \ sla d \ adc hl,hl sll c \ rl b sbc hl,bc jr nc,$+3 add hl,bc sbc a,a \ add a,a \ inc a \ add a,c \ ld c,a
sla e \ adc hl,hl \ sla e \ adc hl,hl sll c \ rl b sbc hl,bc jr nc,$+3 add hl,bc sbc a,a \ add a,a \ inc a \ add a,c \ ld c,a
sla e \ adc hl,hl \ sla e \ adc hl,hl sll c \ rl b sbc hl,bc jr nc,$+3 add hl,bc sbc a,a \ add a,a \ inc a \ add a,c \ ld c,a
sll c \ rl b sla e \ adc hl,hl \ sla e \ adc hl,hl jr nc,$+9 or a sbc hl,bc inc c jp $+13 sbc hl,bc jr nc,$+3 add hl,bc sbc a,a \ add a,a \ inc a \ add a,c \ ld c,a
sla e \ adc hl,hl \ jr nc,$+4 inc c \ ret sla e \ adc hl,hl \ jr nc,$+8 sbc hl,bc \ or a \ jp $+7 or a \ sbc hl,bc \ ret c scf \ sbc hl,bc \ ret c inc c \ ret
665
« on: November 26, 2013, 04:16:45 pm »
I meant to post a few days ago that I thought this was awesome o.o
666
« on: November 26, 2013, 04:07:49 pm »
remove all power and wait. then wait longer. maybe sleep a night before powering back up. The problem is very likely to go away.
I would also do this. I think 9 hours is how long I have heard for the RAM to be completely erased using this method, but if you have the backup battery in, it won't work (since it is used to supply the power needed to keep the RAM from clearing).
668
« on: November 26, 2013, 09:40:36 am »
Now I wish that I was more familiar with the TI-89 LCD. However, I am familiar with the 84+. In some later models of the 84+, there is an instruction that can be sent to the LCD to do similar flips (horizontal, vertical and horizontal+vertical). When it first happened to me, I just let it set with no batteries in the calc (all 4 removed, plus the back up battery removed), but I don't know for how long. My idea was to make sure the LCD was without power for long enough that its RAM reset. It wasn't fixed by an OS install, ram clear, total memory clear, or anything like that because the LCD has its own separate RAM. For the T-89, I could not find documentation in the LCD's data sheet, but I also am bad at reading those. If I could figure out which port to write to, I would attempt to write a program that just writes values to the LCD in descending order until the LCD flipped back. EDIT: In the end, I just asked about my LCD and calc84maniac told me about the new LCDs at which point I had fun flipping LCDs
669
« on: November 26, 2013, 01:11:04 am »
It is almost done on our part, then we will hopefully open to community judging shortly. I am not sure about the time frame, though
670
« on: November 24, 2013, 01:37:16 pm »
Wow, that is cool! I emailed my professor about this since he is doing a Raspberry Pi course next semester.
671
« on: November 21, 2013, 08:07:02 pm »
[rambling] Yeah, after analysing, the method I gave uses one less multiplication than yours, the same number of divisions and square roots. However, mine also uses arctangent, and arctangent is slower than the saved multiplication, so in all, my routine would be slower. In assembly, I could optimise the division in both cases, but your multiplication would be trivial and fast whereas my square root would be faster than yours (only 8 bits of precision would be needed). [/rambling]
Anyways, after looking at the graph, there are actually a few values that are off by a little more than 1, but that is still very accurate and excellent. If you need speed, though, you probably already know that table methods are great. In fact, you can use the fact that it is basically linear from [-89,89] to make only a table from 90 to 128 and they only need to be 1 byte. Here is a routine that gets exact rounded values (111 bytes):
acos: ;Input: ; L is the signed int from [-128,127] where -128 corresponds to -1 ;Output: ; HL ld h,0 ld a,l or a jp p,acossub0 neg call acossub0 ld a,128 sub l ld l,a ret acossub0: cp 14 jr c,$+7 cp 57 jr nc,$+3 dec a cp 68 jp nc,acossub1 inc a ld bc,0530h cp c \ jr c,$+3 \ sub c rla \ djnz $-5 or $E0 add a,65 ld l,a ret acossub1: ;now sub 68 ;between 0 and 21, slope is -2/5 sub 22 jr nc,acossub2 ld c,5 \ ld l,h inc l \ add a,c \ jr nc,$-2 sub 3 \ ld a,l adc a,a add a,1Fh ld l,a ret acossub2: ;original a>=90 ;between 0 and 17, slope is -1/2 sub 18 jr nc,acossub3 rra cpl add a,18h ld l,a ret ;original a>=107 acossub3: ld hl,acosLUT add a,l ld l,a jr nc,$+3 inc h ld l,(hl) ld h,0 ret acosLUT: .db $17 .db $16 .db $16 .db $15 .db $15 .db $14 .db $13 .db $13 .db $12 .db $11 .db $10 .db $F .db $E .db $E .db $D .db $B .db $A .db $9 .db $7 .db $5
And if you are okay with tiny error of only 1, this is 21 bytes smaller and around 300 t-states worst case:
acos: ;Input: ; L is the signed int from [-128,127] where -128 corresponds to -1 ;Output: ; HL ld h,0 ld a,l or a jp p,acossub0 neg call acossub0 ld a,128 sub l ld l,a ret acossub0: cp 90 jp nc,acossub1 inc a ld bc,0530h cp c \ jr c,$+3 \ sub c rla \ djnz $-5 or $E0 add a,65 ld l,a ret acossub1: ;now sub 90 ld hl,acosLUT add a,l ld l,a jr nc,$+3 inc h ld l,(hl) ld h,0 ret acosLUT: .db $20 .db $20 .db $1F .db $1F .db $1E .db $1E .db $1D .db $1D .db $1C .db $1C .db $1B .db $1B .db $1A .db $1A .db $19 .db $19 .db $18 .db $18 .db $17 .db $16 .db $16 .db $15 .db $15 .db $14 .db $13 .db $13 .db $12 .db $11 .db $10 .db $F .db $E .db $E .db $D .db $B .db $A .db $9 .db $7 .db $5
673
« on: November 21, 2013, 08:44:49 am »
Wow, nice! How well does it work near the end points? I was just going to compute asin() and acos() from atan().
674
« on: November 19, 2013, 12:15:26 pm »
EDIT:(27-Oct-2015) Updated at the end of the original post with a muuuch better routine.
I wrote this routine today for generating pseudorandom numbers. If I did the math correctly, it has a period of 4292870399. To think of it differently, it executes in about 1430 1592 t-states , so that means at 15MHZ, it would take about 4 days, 19 hours, 49 minutes, 41 seconds to loop back to the start of the over 4 billion number sequence. Or, if you generated one number per second, it would take over 136 years to finish the cycle. Rand24: ;Inputs: seed1,seed2 ;Outputs: ; HLA is the pseudo-random number ; seed1,seed2 incremented accordingly ;Destroys: BC,DE ;Notes: ; seed1*243+83 mod 65519 -> seed1 ; seed2*251+43 mod 65521 -> seed2 ; Output seed1*seed2 ld hl,(seed1) xor a ld b,h \ ld c,l ld de,83 add hl,hl \ rla ;2 add hl,bc \ adc a,d ;3 add hl,hl \ rla ;6 add hl,bc \ adc a,d ;7 add hl,hl \ rla ;14 add hl,bc \ adc a,d ;15 add hl,hl \ rla ;30 add hl,hl \ rla ;60 add hl,hl \ rla ;120 add hl,bc \ adc a,d ;121 add hl,hl \ rla ;242 add hl,bc \ adc a,d ;243 add hl,de \ adc a,d ;243x+83 ;now AHL mod 65519 ; Essentially, we can at least subtract A*65519=A(65536-17), so add A*17 to HL ex de,hl ld l,a ld b,h ld c,l add hl,hl add hl,hl add hl,hl add hl,hl add hl,bc add hl,de ld de,65519 jr nc,$+5 or a \ sbc hl,de or a \ sbc hl,de jr nc,$+3 add hl,de ld (seed1),hl ;seed1 done, now we need to do seed2 ld hl,(seed2) ; seed1*243+83 mod 65519 -> seed1 ; seed2*251+43 mod 65521 -> seed2 ; Output seed1*seed2 xor a ld b,h \ ld c,l ld de,43 add hl,hl \ rla ;2 add hl,bc \ adc a,d ;3 add hl,hl \ rla ;6 add hl,bc \ adc a,d ;7 add hl,hl \ rla ;14 add hl,bc \ adc a,d ;15 add hl,hl \ rla ;30 add hl,bc \ adc a,d ;31 add hl,hl \ rla ;62 add hl,hl \ rla ;124 add hl,bc \ adc a,d ;125 add hl,hl \ rla ;250 add hl,bc \ adc a,d ;251 add hl,de \ adc a,d ;251x+83 ;now AHL mod 65521 ; Essentially, we can at least subtract A*65521=A(65536-15), so add A*15 to HL ex de,hl ld l,a ld b,h ld c,l add hl,hl add hl,hl add hl,hl add hl,hl sbc hl,bc add hl,de ld de,65521 jr nc,$+5 or a \ sbc hl,de or a \ sbc hl,de jr nc,$+3 add hl,de ld (seed2),hl ;now seed1 and seed 2 are computed ld bc,(seed1) ex de,hl call BC_Times_DE ex de,hl ld l,b ld h,0 ld b,h ld c,l add hl,hl add hl,hl add hl,bc add hl,hl add hl,hl add hl,bc add hl,hl add hl,bc ld c,d ld d,e ld e,a ld a,c sbc hl,bc sbc a,b ret nc ld c,43 add hl,bc ret ;now do BC_times_DE BC_Times_DE: ;BHLA is the result ld a,b or a ld hl,0 ld b,h ;1 add a,a jr nc,$+4 ld h,d ld l,e ;2 add hl,hl rla jr nc,$+4 add hl,de adc a,b ;227+10b-7p add hl,hl rla jr nc,$+4 add hl,de adc a,b
add hl,hl rla jr nc,$+4 add hl,de adc a,b
add hl,hl rla jr nc,$+4 add hl,de adc a,b
add hl,hl rla jr nc,$+4 add hl,de adc a,b
add hl,hl rla jr nc,$+4 add hl,de adc a,b
add hl,hl rla jr nc,$+4 add hl,de adc a,b
;=== ;AHL is the result of B*DE*256 push hl ld h,b ld l,b ld b,a ld a,c ld c,h ;1 add a,a jr nc,$+4 ld h,d ld l,e ;2 add hl,hl rla jr nc,$+4 add hl,de adc a,c ;227+10b-7p add hl,hl rla jr nc,$+4 add hl,de adc a,c
add hl,hl rla jr nc,$+4 add hl,de adc a,c
add hl,hl rla jr nc,$+4 add hl,de adc a,c
add hl,hl rla jr nc,$+4 add hl,de adc a,c
add hl,hl rla jr nc,$+4 add hl,de adc a,c
add hl,hl rla jr nc,$+4 add hl,de adc a,c
pop de ;Now BDE*256+AHL ld c,a ld a,l ld l,h ld h,c add hl,de ret nc inc b ;BHLA is the 32-bit result ret seed1: .dw 0 seed2: .dw 0
To test its 'randomness' I only used HL and it did not exhibit a perfectly uniform random distribution (standard deviation was slightly off from the expected value). However, it seems to be on par with the routine used by the OS and I believe I am using a modified version of that. Now I will feel confident to use this in my math libraries EDIT: Added a mod 16777259 to the output to fix a flaw. EDIT: The much better routine: - It passes all the tests at CAcert Labs
- The cycle size is almost 4.3 million times longer .
- It is 550% faster (287cc versus 1592cc)
- It would take over 11,184,544 years at the calculator's max speed to reach the full cycle.
rand: ;Tested and passes all CAcert tests ;Uses a very simple 32-bit LCG and 32-bit LFSR ;it has a period of 18,446,744,069,414,584,320 ;roughly 18.4 quintillion. ;291cc seed1_0=$+1 ld hl,12345 seed1_1=$+1 ld de,6789 ld b,h ld c,l add hl,hl \ rl e \ rl d add hl,hl \ rl e \ rl d inc l add hl,bc ld (seed1_0),hl ld hl,(seed1_1) adc hl,de ld (seed1_1),hl ex de,hl seed2_0=$+1 ld hl,9876 seed2_1=$+1 ld bc,54321 add hl,hl \ rl c \ rl b ld (seed2_1),bc sbc a,a and %11000101 xor l ld l,a ld (seed2_0),hl ex de,hl add hl,bc ret
EDIT (28 August 2019): Hey, so here is a compact version from a few years ago: ;#define smc ;uncomment if you are using SMC rand16: ;collaboration by Zeda with Runer112 ;160cc or 148cc if using SMC ;26 bytes ;cycle: 4,294,901,760 (almost 4.3 billion) #ifdef smc seed1=$+1 ld hl,9999 #else ld hl,(seed1) #endif ld b,h ld c,l add hl,hl add hl,hl inc l add hl,bc ld (seed1),hl #ifdef smc seed2=$+1 ld hl,9999 #else ld hl,(seed2) #endif add hl,hl sbc a,a and %00101101 xor l ld l,a ld (seed2),hl add hl,bc ret
And here is a different routine that is faster and might be better (it is on the tests I am using): xsp32: ;Inputs: (seed1), (seed2), and (seed3) are 16-bit seeds. (seed1) and (seed2) can't both be 0. ;Outputs: HL is the pseudorandom number ;Destroys: A,DE,BC ;cycle: 281,474,976,645,120 ;It would take about 185 years at 15MHz to repeat ;min: 258cc (236cc if using SMC) ;max: 288cc (266cc if using SMC) ;avg: 273cc (251cc if using SMC) ;63 bytes (62 bytes if using SMC) #ifdef SMC seed1 = $+1 ld hl,12345 seed2 = $+1 ld de,6789 #else ld hl,(seed1) ld de,(seed2) #endif
;first, XOR it with itself, shifted left 23 bits ;low bit of d needs to be shifted in ld a,h rra ld a,l rra jr nc,+_ rl e ccf rr e _: xor d ld d,a
;XOR it with itself, shifted right 15 bits ld a,h rla ld a,e rla xor l ld l,a
ld a,e rla ld a,d rla jr nc,+_ rr e ccf rl e _: xor h ld h,a
;XOR it with itself, shifted left 17 bits ;HL<<1 ld (seed1),hl add hl,hl ld a,h xor d ld h,a
ld a,l xor e ld l,a ld (seed2),hl ex de,hl
#ifdef SMC seed3 = $+1 ld hl,33333 #else ld hl,(seed3) #endif
inc hl inc h ld (seed3),hl add hl,de ret
It has a smaller period, but still far larger than a calc needs. It uses smaller state, and combines a 32-bit xorshift with a basic 16-bit counter (increments by 257). Just a 32-bit xorshift routine, which is pretty decent on its own: xs32: ;32-bit xorshift ;seed^=seed<<23 ;seed^=seed>>15 ;seed^=seed<<17 ;min: 209cc (193cc if using SMC) ;max: 239cc (223cc if using SMC) ;avg: 224cc (208cc if using SMC) ;53 bytes (52 bytes if using SMC) #ifdef SMC seed1 = $+1 ld hl,12345 seed2 = $+1 ld de,6789 #else ld hl,(seed1) ld de,(seed2) #endif
;first, XOR it with itself, shifted left 23 bits ;low bit of d needs to be shifted in ld a,h rra ld a,l rra jr nc,+_ rl e ccf rr e _: xor d ld d,a
;XOR it with itself, shifted right 15 bits ld a,h rla ld a,e rla xor l ld l,a
ld a,e rla ld a,d rla jr nc,+_ rr e ccf rl e _: xor h ld h,a
;XOR it with itself, shifted left 17 bits ;HL<<1 ld (seed1),hl add hl,hl ld a,h xor d ld h,a
ld a,l xor e ld l,a ld (seed2),hl ret
675
« on: November 16, 2013, 09:51:46 am »
Here is my 8.8 fixed point, table-based arctangent routine:
arctan_88: ;Input: ; D.E ;Output: atan(D.E)->D.E push de ld a,d or a jp p,$+5 neg ld d,a dec a jr nz,checkneedinv inc e \ dec e \ jr nz,checkneedinv pop af \ rla \ ld de,201 \ ret nc \ ld de,-201 \ ret checkneedinv: inc a call nz,DEgt1_Inv ;0.E is the value to atan ld hl,adjustatan push hl ld a,e cp 46 \ ret c dec a \ cp 42h \ ret c dec a \ cp 4Eh \ ret c dec a \ cp 57h \ ret c dec a \ cp 5Eh \ ret c dec a \ cp 64h \ ret c dec a \ cp 6Ah \ ret c dec a \ cp 6Fh \ ret c sub 6Fh \ ld e,a ld hl,atanlut add hl,de ld a,(hl) ret adjustatan: ld e,a pop bc ld a,b or a jp p,$+5 neg jr z,$+9 ld hl,402 or a sbc hl,de ex de,hl rl b ret nc xor a sub e ld e,a sbc a,a sub d ld d,a ret DEgt1_Inv: ;Works if DE>1 ld hl,256 ld b,8 InvLoop: add hl,hl sbc hl,de jr nc,$+3 add hl,de adc a,a djnz InvLoop cpl ld e,a ld d,b ret atanlut: .db $6F .db $6F .db $70 .db $71 .db $72 .db $73 .db $73 .db $74 .db $75 .db $76 .db $77 .db $77 .db $78 .db $79 .db $7A .db $7B .db $7B .db $7C .db $7D .db $7E .db $7F .db $7F .db $80 .db $81 .db $82 .db $82 .db $83 .db $84 .db $85 .db $85 .db $86 .db $87 .db $88 .db $88 .db $89 .db $8A .db $8B .db $8B .db $8C .db $8D .db $8E .db $8E .db $8F .db $90 .db $90 .db $91 .db $92 .db $93 .db $93 .db $94 .db $95 .db $95 .db $96 .db $97 .db $97 .db $98 .db $99 .db $9A .db $9A .db $9B .db $9C .db $9C .db $9D .db $9E .db $9E .db $9F .db $A0 .db $A0 .db $A1 .db $A2 .db $A2 .db $A3 .db $A3 .db $A4 .db $A5 .db $A5 .db $A6 .db $A7 .db $A7 .db $A8 .db $A9 .db $A9 .db $AA .db $AA .db $AB .db $AC .db $AC .db $AD .db $AD .db $AE .db $AF .db $AF .db $B0 .db $B0 .db $B1 .db $B2 .db $B2 .db $B3 .db $B3 .db $B4 .db $B5 .db $B5 .db $B6 .db $B6 .db $B7 .db $B7 .db $B8 .db $B9 .db $B9 .db $BA .db $BA .db $BB .db $BB .db $BC .db $BC .db $BD .db $BE .db $BE .db $BF .db $BF .db $C0 .db $C0 .db $C1 .db $C1 .db $C2 .db $C2 .db $C3 .db $C3 .db $C4 .db $C4 .db $C5 .db $C6 .db $C6 .db $C7 .db $C7 .db $C8 .db $C8 .db $C9
Pages: 1 ... 43 44 [45] 46 47 ... 317
|