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 ... 76 77 [78] 79 80 ... 317
1156
« on: February 11, 2013, 06:01:13 pm »
I did not have the problem you described, but I do see a big problem with the code and a bunch of smaller problems (maybe). The big problem is that they never used End for one of their While loops And since they kept re-entering the While loop without finishing it with an End, it would eventually fill the stack causing a crash, most likely .__. The little problems are just regular coding optimisations For example, Grammer does not use negative numbers, so Y>0 is the same as Y≠0. As well, there are so many extra DispGraph's and they are slowing down the program. Full1
Is the same as: Full
While Y>0
Since Grammer only has non-negative integers (0,1,2,3,4,...,65535), you can do: While Y
Instead of 'X:-X>0:→X'you can just do X-X>0→X or even better, since Grammer doesn't have negative numbers, X-!X→X In fact, for movement, this is better: X+K=3 -K=2 If <86 →X
Say X=0 and you press [Left]. Then the first two lines do 0-1 which is 65535, and since 65535≥86, it isn't stored to X. Here is how I optimised/fixed it: .0:Return "3C72F3FFFFFF7E3C→S 31→Y 47→X While Y=abs(Y ClrDraw Rect(0,55,7,96,8 randInt(0,86 Line(,55,7,12,9 For(55 getKey→K X+K=3 -K=2 If <86 →X Tangent(1,8 ;shift the graph buffer up 1 pixel Sprite(10,S,Y,X ;The last two arguments can be omitted if they are 1,8 DispGraph Sprite(10,S,Y,X Y-!!Rect(X,Y,9,8,15→Y ;Rect(X,Y,H,W,15) is a pxl-Test( for the border. End End Stop
It is not perfect, but it works a lot faster (faster than before, even without Full). And more, it is now easy to add more barriers on the screen at once! Here is the screenie of the version I made with better collision detection and variable speed and stuff
1157
« on: February 11, 2013, 07:27:25 am »
Yes, add, sub, adc, and sbc with hl for immediate values would have been nice o.o
1158
« on: February 10, 2013, 07:29:31 pm »
I always think of it as ohm-nee-may-gah
I typically pronounce it this way, but I think Fireicee1's way is the way it is intended to be pronounced.
1159
« on: February 10, 2013, 01:26:23 pm »
I like how it looks. I wonder if it can be optimised more o.o
1160
« on: February 10, 2013, 11:49:04 am »
Wait, so :
r3^10→{a--}
Doesn't work? (You will need to initialise A as 8457h instead of 8456h) I think it is more optimised by 3 bytes if you do it that way (and 16 t-states).
1161
« on: February 09, 2013, 07:16:25 pm »
@Spenceboy: Could you upload that and will it fit on my calc? o_o I want to show that to non-believers
1162
« on: February 05, 2013, 06:39:47 am »
@chickendude: I have thought about that, too o.o What if there was a way to refer to a specific shadow register, even if it were an extended instruction. This way you could do something like ex hl',hl or copy hl,hl'. @tr1p1ea: If there was such a command, it would detract from the fun of creating a multiplication or division routine
1163
« on: February 05, 2013, 06:30:43 am »
I personally like the last version that you presented. It loses readability, but I really think that that is okay with macro's. We can just describe what they do in a readme or something if it is really needed.
As well, I am not sure how you parse the files, but the way I have been doing it is to basically read the source as a type of program (I basically used ideas that I had already developed in Grammer+FileSyst). When a letter is concatenated with an opening parentheses, it tells the parser that it is a macro, so it searches the file for the macro and treats it as a "subroutine" of source code. This way you can add in some complicated macros for sure. I have been thinking of doing this for defining variables, too. It would really slow down compile times, but it would allow the user to define variables like String = "Hello" and then adding in a command like len(String) would make this easy:
.db len(String),String
I have wished to be able to this quite often instead of needing to count the length of a string with PC math and labels.
1164
« on: February 04, 2013, 01:03:55 pm »
It's interesting to see how our syntax/style differs even on bits of code that do exactly the same thing
I noticed that, too, it is kind of neat. I noticed that I mask A and then shift, whereas you shift, then mask. I've done both, but I typically do the former. And if you don't mind sacrificing just a few clocks (altogether maybe between 8-64), maybe you could try this and save 2 bytes:
Nice, I like that! When B is not 0, that is actually anywhere from 6 cycles faster to 18 cycles slower, so I think that is a great trade-off. By adding a byte, I can make your routine anywhere from 0 cycles to 24 cycles faster when b>0 ComputeByte: neg ; or 'cpl \ inc a and 7 ld b,a ld a,FFh ret z add a,a djnz $-1 ret
This happens to be faster than my original and smaller by one byte. Still, it is larger than yours
1165
« on: February 04, 2013, 07:23:40 am »
EDIT Five years later, I found my code didn't work that well At the bottom of this post is a working routine, but not ideal.
Hmm, for 'rectangle_loop_x' and 'rectangle_loop_x_end' you have 'or (hl)' which I think needs to be SMC'd. I decided to try and optimise my code a bit and I managed to optimise it for speed in most cases and size. Unfortunately, the code is still much bigger than chickendude's at 133 bytes To give an indicator of speed (6MHz): my old routine, 9x18 rectangle : 1926 times in two seconds my new routine, 9x18 : 5668 times in two seconds chickendude's old routine : 1287 times in two seconds chickendude's new routine : untested .__. So for cases where you don't need crazy speed, chickendude's is still very fast and much smaller (73 bytes versus 133). Rectangle_or: ld a,$B6 jr Rectangle Rectangle_xor: ld a,$AE Rectangle: ; DE = (x,y) ; BC = (height,width) ld (smc_logic1),a ld (smc_logic0),a push de push bc push bc ld a,d call ComputeByte ld (smc_FirstByte),a ex (sp),hl ld a,d neg and 7 ld b,a ld a,l sub b ex (sp),hl ld c,a call ComputeByte cpl ld (smc_LastByte),a ld b,a sra c \ sra c \ sra c inc c ; ld a,c ; and %11111000 ; rra \ rra \ rra ; inc a ; ld c,a
ld a,d ld d,0 ld h,d ld l,e add hl,hl add hl,de add hl,hl add hl,hl and %11111000 rra \ rra \ rra add a,GBUF_LSB ld e,a ld d,GBUF_MSB add hl,de ;HL points to the first byte pop de ;D is the height ;E is the number of bytes wide inc c dec c jr nz,RectOverLoop-1 ld a,(smc_FirstByte) and b ld c,a ;value ld b,d ;height ld de,12 ld a,c smc_logic1: or (hl) ld (hl),a add hl,de djnz $-4 pop bc pop de ret ld e,c RectOverLoop: ld b,e ld c,12 .db 3Eh ;start of ld a,* smc_FirstByte: .db 0 RectLoop: smc_logic0: or (hl) ld (hl),a inc hl dec c jr z,ExitLoop ld a,-1 djnz RectLoop ; jp p,$+4 ; dec b .db 3Eh ;start of ld a,* smc_LastByte: .db 0 or (hl) ld (hl),a add hl,bc ExitLoop: dec d jr nz,RectOverLoop pop bc pop de ret
ComputeByte: and 7 ld b,a ld a,80h jr z,$+5 rrca djnz $-1 add a,a dec a ret
Necro-edit:This code is working, and it performs clipping. Using the above benchmarks, this code draws approximately 4240 of those rectangle per two seconds at 6MHz on an actual calc. The downside is the size The core routine is 119 bytes, and the code for XOR rectangle is an additional 61 bytes, OR rectangle is also 61 bytes, and Erase rectangle is 66 bytes. They do not preserve registers. However, they were made to run in an app, so they don't rely on SMC-- If they did use SMC, it could probably fit all of the routines in just under 200 bytes. ;; ;;rectXOR ;;rectOR ;;rectErase ;; (B,C) = (x,y) signed ;; (D,E) = (w,h) unsigned ;; HL points to buf
rectXOR: push hl call rectSub pop ix ret nc ex de,hl add ix,de ex de,hl push ix pop hl dec b jp m,xorrect0 inc b xor_rect_loop: push bc push hl ld a,(hl) \ xor d \ ld (hl),a \ inc hl dec b jr z,$+8 ld a,(hl) \ cpl \ ld (hl),a \ inc hl \ djnz $-4 ld a,(hl) \ xor e \ ld (hl),a ld bc,12 pop hl add hl,bc pop bc dec c jr nz,xor_rect_loop ret xorrect0: ld a,d and e ld b,c ld c,a ld de,12 ld a,c xor (hl) ld (hl),a add hl,de djnz $-4 ret rectErase: push hl call rectSub pop ix ret nc ex de,hl add ix,de ex de,hl push ix pop hl ld a,d cpl ld d,a ld a,e cpl ld e,a dec b jp m,eraserect0 inc b erase_rect_loop: push bc push hl ld a,(hl) \ and d \ ld (hl),a \ inc hl dec b jr z,$+7 xor a ld (hl),a \ inc hl \ djnz $-2 ld a,(hl) \ and e \ ld (hl),a ld bc,12 pop hl add hl,bc pop bc dec c jr nz,erase_rect_loop ret eraserect0: ld a,d xor e ld b,c ld c,a ld de,12 ld a,c and (hl) ld (hl),a add hl,de djnz $-4 ret rectOR: push hl call rectSub pop ix ret nc ex de,hl add ix,de ex de,hl push ix pop hl dec b jp m,orrect0 inc b or_rect_loop: push bc push hl ld a,(hl) \ or d \ ld (hl),a \ inc hl dec b jr z,$+8 ld c,-1 ld (hl),c \ inc hl \ djnz $-2 ld a,(hl) \ or e \ ld (hl),a ld bc,12 pop hl add hl,bc pop bc dec c jr nz,or_rect_loop ret orrect0: ld a,d and e ld b,c ld c,a ld de,12 ld a,c or (hl) ld (hl),a add hl,de djnz $-4 ret rectsub: ;(B,C) = (x,y) signed ;(D,E) = (w,h) unsigned ;Output: ; Start Mask D ; End Mask E ; Byte width B ; Height C ; buf offset HL bit 7,b jr z,+_ ;Here, b is negative, so we have to add width to x. ;If the result is still negative, the entire box is out of bounds, so return ;otherwise, set width=newvalue,b=0 ld a,d add a,b ret nc ld d,a ld b,0 _: bit 7,c jr z,+_ ld a,e add a,c ret nc ld e,a ld c,0 _: ;We have clipped all negative areas. ;Now we need to verify that (x,y) are on the screen. ;If they aren't, then the whole rectangle is off-screen so no need to draw. ld a,b cp 96 ret nc ld a,c cp 64 ret nc ;Let's also verfiy that height and width are non-zero: ld a,d or a ret z ld a,e or a ret z ;Now we need to clip the width and height to be in-bounds add a,c cp 65 jr c,+_ ;Here we need to set e=64-c ld a,64 sub c ld e,a _: ld a,d add a,b cp 97 jr c,+_ ;Here we need to set d=96-b ld a,96 sub b ld d,a _: ;B is starting X ;C is starting Y ;D is width ;E is height
push bc ld a,b and 7 ld b,a ld a,-1 jr z,+_ rra \ djnz $-1 _: inc a cpl ld h,a ;start mask
ld a,b add a,d and 7 ld b,a ld a,-1 jr z,+_ rra \ djnz $-1 _: inc a ld l,a ;end mask ex (sp),hl ;stack now holds DE ;HL is now the coordinates ;B=0, C=height ;A,BC are free to destroy ld a,h ld h,b add hl,hl add hl,bc add hl,hl add hl,hl ld b,a rrca rrca rrca and 31 add a,l ld l,a jr nc,$+3 inc h
;B is the starting x, D is width ;Only A,B,D,E are available ld a,b add a,d and $F8 ld d,a
ld a,b and $F8 ld b,a ld a,d sub b rrca rrca rrca ld b,a ld c,e pop de scf ret
1166
« on: February 02, 2013, 05:44:33 pm »
Yes, I saw that there was a problem yesterday, but it is now fixed.
1167
« on: February 02, 2013, 07:41:26 am »
This is a drawing that I never finished in my drawing class. We were supposed to sketch two models from some given perspective:
1168
« on: February 02, 2013, 07:19:24 am »
Thomas is my last name
1169
« on: February 01, 2013, 04:41:30 pm »
Is there supposed to be a confirmation email or something?
You just wait and your entry request should be accepted within 24 hours, I think.
1170
« on: February 01, 2013, 01:41:30 pm »
I might be able to find a friend to do the Skype stuff o.o
Pages: 1 ... 76 77 [78] 79 80 ... 317
|