Qbasicnews.com

Full Version: 100% QB game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Nemesis, your code would be even faster if you replace every GOSUB by the actual subroutine they are calling in the Put sub. GOSUB takes time Wink
Quote:Nemesis, your code would be even faster if you replace every GOSUB by the actual subroutine they are calling in the Put sub. GOSUB takes time Wink

Sorry na_th_an, I wasn't aware of any GOSUBS in the PUT subroutine. Maybe you were thinking something different than what
you worte/posted?

Glad to see you took the time to look at my lib.

To let you know, there are many things that could be done to increase the speed but, I'm not going to spend the time to incorporate these things currently. I might decide to one of these days though :wink:
Feel free to post any suggestions, if I use your idea, Ill add you to the credits, yipeeee!!!! :bounce:

Umm... bye.

Nemesis
I meant this:

Code:
[...]
  CASE &H1
    DEF SEG = TS&
    GOSUB tB0
    DEF SEG = DS&
    GOSUB dB0
[...]

I dunno where it belongs. I suggest to paste the actual code instead of the GOSUBs. You gain the time took by four jumps.
Quote:I meant this:

Code:
[...]
  CASE &H1
    DEF SEG = TS&
    GOSUB tB0
    DEF SEG = DS&
    GOSUB dB0
[...]

I dunno where it belongs. I suggest to paste the actual code instead of the GOSUBs. You gain the time took by four jumps.

True na_th_an, it would be faster but, I'm not sure if
you are fully aware of the actual structure of this routine.
The GOSUB you are refering to is only called once if the
number of bytes it's transfering is not a multiple of 16.
IF it's a multiple of 16 then there's no execution of this
part of the routine. Also, if I were too, (hard code sort of speaking)
the actual routine it calls via. GOSUB then I would be using
precious string space which is probablly one of QB's biggest
limitation. This lib is geared towards speed but, it also focuses
on preserving memory, and other important aspects needed when
using a limited language such as QB Smile

eg #1SadTaking out the GOSUBS)...
Code:
'
  SELECT CASE (BYTES& MOD &H10)
   CASE &H1
    DEF SEG = TS&
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H0), b0
   CASE &H2
    DEF SEG = TS&
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &H3
    DEF SEG = TS&
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &H4
    DEF SEG = TS&
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &H5
    DEF SEG = TS&
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &H6
    DEF SEG = TS&
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &H7
    DEF SEG = TS&
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &H8
    DEF SEG = TS&
    b7 = PEEK(bt(&H7))
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H7), b7
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &H9
    DEF SEG = TS&
    b8 = PEEK(bt(&H8))
    b7 = PEEK(bt(&H7))
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H8), b8
    POKE bd(&H7), b7
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &HA
    DEF SEG = TS&
    b9 = PEEK(bt(&H9))
    b8 = PEEK(bt(&H8))
    b7 = PEEK(bt(&H7))
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&H9), b9
    POKE bd(&H8), b8
    POKE bd(&H7), b7
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &HB
    DEF SEG = TS&
    ba = PEEK(bt(&HA))
    b9 = PEEK(bt(&H9))
    b8 = PEEK(bt(&H8))
    b7 = PEEK(bt(&H7))
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&HA), ba
    POKE bd(&H9), b9
    POKE bd(&H8), b8
    POKE bd(&H7), b7
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &HC
    DEF SEG = TS&
    bb = PEEK(bt(&HB))
    ba = PEEK(bt(&HA))
    b9 = PEEK(bt(&H9))
    b8 = PEEK(bt(&H8))
    b7 = PEEK(bt(&H7))
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&HB), bb
    POKE bd(&HA), ba
    POKE bd(&H9), b9
    POKE bd(&H8), b8
    POKE bd(&H7), b7
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &HD
    DEF SEG = TS&
    bc = PEEK(bt(&HC))
    bb = PEEK(bt(&HB))
    ba = PEEK(bt(&HA))
    b9 = PEEK(bt(&H9))
    b8 = PEEK(bt(&H8))
    b7 = PEEK(bt(&H7))
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&HC), bc
    POKE bd(&HB), bb
    POKE bd(&HA), ba
    POKE bd(&H9), b9
    POKE bd(&H8), b8
    POKE bd(&H7), b7
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &HE
    DEF SEG = TS&
    bd = PEEK(bt(&HD))
    bc = PEEK(bt(&HC))
    bb = PEEK(bt(&HB))
    ba = PEEK(bt(&HA))
    b9 = PEEK(bt(&H9))
    b8 = PEEK(bt(&H8))
    b7 = PEEK(bt(&H7))
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&HD), bd
    POKE bd(&HC), bc
    POKE bd(&HB), bb
    POKE bd(&HA), ba
    POKE bd(&H9), b9
    POKE bd(&H8), b8
    POKE bd(&H7), b7
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
   CASE &HF
    DEF SEG = TS&
    be = PEEK(bt(&HE))
    bd = PEEK(bt(&HD))
    bc = PEEK(bt(&HC))
    bb = PEEK(bt(&HB))
    ba = PEEK(bt(&HA))
    b9 = PEEK(bt(&H9))
    b8 = PEEK(bt(&H8))
    b7 = PEEK(bt(&H7))
    b6 = PEEK(bt(&H6))
    b5 = PEEK(bt(&H5))
    b4 = PEEK(bt(&H4))
    b3 = PEEK(bt(&H3))
    b2 = PEEK(bt(&H2))
    b1 = PEEK(bt(&H1))
    b0 = PEEK(bt(&H0))
    DEF SEG = DS&
    POKE bd(&HF), bf
    POKE bd(&HE), be
    POKE bd(&HD), bd
    POKE bd(&HC), bc
    POKE bd(&HB), bb
    POKE bd(&HA), ba
    POKE bd(&H9), b9
    POKE bd(&H8), b8
    POKE bd(&H7), b7
    POKE bd(&H6), b6
    POKE bd(&H5), b5
    POKE bd(&H4), b4
    POKE bd(&H3), b3
    POKE bd(&H2), b2
    POKE bd(&H1), b1
    POKE bd(&H0), b0
  END SELECT
  '

eg #2:The current structure...
Code:
'
  SELECT CASE (BYTES& MOD &H10)
   CASE &H1
    DEF SEG = TS&
    GOSUB tB0
    DEF SEG = DS&
    GOSUB dB0
   CASE &H2
    DEF SEG = TS&
    GOSUB tB1
    DEF SEG = DS&
    GOSUB dB1
   CASE &H3
    DEF SEG = TS&
    GOSUB tB2
    DEF SEG = DS&
    GOSUB dB2
   CASE &H4
    DEF SEG = TS&
    GOSUB tB3
    DEF SEG = DS&
    GOSUB dB3
   CASE &H5
    DEF SEG = TS&
    GOSUB tB4
    DEF SEG = DS&
    GOSUB dB4
   CASE &H6
    DEF SEG = TS&
    GOSUB tB5
    DEF SEG = DS&
    GOSUB dB5
   CASE &H7
    DEF SEG = TS&
    GOSUB tB6
    DEF SEG = DS&
    GOSUB dB6
   CASE &H8
    DEF SEG = TS&
    GOSUB tB7
    DEF SEG = DS&
    GOSUB dB7
   CASE &H9
    DEF SEG = TS&
    GOSUB tB8
    DEF SEG = DS&
    GOSUB dB8
   CASE &HA
    DEF SEG = TS&
    GOSUB tB9
    DEF SEG = DS&
    GOSUB dB9
   CASE &HB
    DEF SEG = TS&
    GOSUB tBA
    DEF SEG = DS&
    GOSUB dBA
   CASE &HC
    DEF SEG = TS&
    GOSUB tBB
    DEF SEG = DS&
    GOSUB dBB
   CASE &HD
    DEF SEG = TS&
    GOSUB tBC
    DEF SEG = DS&
    GOSUB dBC
   CASE &HE
    DEF SEG = TS&
    GOSUB tBD
    DEF SEG = DS&
    GOSUB dBD
   CASE &HF
    DEF SEG = TS&
    GOSUB tBE
    DEF SEG = DS&
    GOSUB dBE
   END SELECT
tBF: BF = PEEK(bt(&HF))
tBE: BE = PEEK(bt(&HE))
tBD: bd = PEEK(bt(&HD))
tBC: BC = PEEK(bt(&HC))
tBB: bb = PEEK(bt(&HB))
tBA: BA = PEEK(bt(&HA))
tB9: b9 = PEEK(bt(&H9))
tB8: b8 = PEEK(bt(&H8))
tB7: b7 = PEEK(bt(&H7))
tB6: b6 = PEEK(bt(&H6))
tB5: b5 = PEEK(bt(&H5))
tB4: b4 = PEEK(bt(&H4))
tB3: b3 = PEEK(bt(&H3))
tB2: B2 = PEEK(bt(&H2))
tB1: B1 = PEEK(bt(&H1))
tB0: B0 = PEEK(bt(&H0))
     '
     RETURN
     '
dBF: POKE bd(&HF), BF
dBE: POKE bd(&HE), BE
dBD: POKE bd(&HD), bd
dBC: POKE bd(&HC), BC
dBB: POKE bd(&HB), bb
dBA: POKE bd(&HA), BA
dB9: POKE bd(&H9), b9
dB8: POKE bd(&H8), b8
dB7: POKE bd(&H7), b7
dB6: POKE bd(&H6), b6
dB5: POKE bd(&H5), b5
dB4: POKE bd(&H4), b4
dB3: POKE bd(&H3), b3
dB2: POKE bd(&H2), B2
dB1: POKE bd(&H1), B1
dB0: POKE bd(&H0), B0
     '
     RETURN
     '

Cya,

Nemesis
Use real SUBS/FUNCTIONS.

Works just fine, although it doesent really matter that much.
Quote:Use real SUBS/FUNCTIONS.

Works just fine, although it doesent really matter that much.

GOSUB stores 4 bytes on stack, performs a jump. That's two integer PUSHes and a JMP. RETURN retrieves those 4 bytes from stack, and then performs a jump. That's two integer POPs and a JMP. That takes time. If you paste the code directly, you save that time.

Real SUBs FUNCTIONs take even more time, as parameters also have to be pushed/popped into the stack.
I know, for time critical you should always unroll, and call as few procs as possible.

Longer code is a cosmetic thing, doesent really matter to the compiler (unless QB, which chokes ofcourse)
Well I decided to optimize my V13hCPY subroutine a bit.
Taking into consideration to what na_th_an suggested to increase
the speed of this routine, and still keeping the routine at a favorable size to save memory. So, it was slightly faster and only slightly larger so it worked out well. I also whipped up a similar V13hCPY routine to work as a PUT routine. This routine amazingly is as fast as a QB's PUT (X,Y), 0,OR (Called through the V13hPUT subroutine as "ANDXOR"....
Check out in my previous posts for the source code of the whole lib! (The new improved routines will be included with my newest edit of the post containing the source code!)

Cya,

Nemesis
I don't understand why you say that changing the GOSUBs by the actual routine replicated 1000 times takes more memory. It takes less: you are not pushing anything to the stack.
Quote:I don't understand why you say that changing the GOSUBs by the actual routine replicated 1000 times takes more memory. It takes less: you are not pushing anything to the stack.

na_th_an...

(More $pace) = (more memory), period!

Nemesis


P.s...

na_th_an, if you just track the logic of my routine then you might get a better understanding for my reasoning of not unrolling these frequently accessed routines.(Or just review my previous posts where I discussed my reasoning.) And also, what's the point in using subroutines, functions, No GOTO's :lol: , basic structured coding ethics, etc... I might as well just use another language if
I'm not going to utilize some of the better ascpects of the language I'm using.
[/quote]
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15