Jump to content
Jet Set Willy & Manic Miner Community

Random technical question


Spider

Recommended Posts

As the original JSW (and MM) both keep some data in lower memory (contended memory to be exact) such as the attribute and screen buffer data, assuming one relocated this to uncontended memory, that being > 32768 would there be any noticeable speed increase in the game itself ?

I'm only basing this on the assumption that contended memory might be slower, although with interrupts disabled I'm not sure. Sorry.

I suspect any increase would not be noted, I do realise that the change to LDI vs LDIR would and does offer a bit of a boost though.

Link to comment
Share on other sites

Contended memory stretches timing cycles. It has a big impact.

Note this code is designed to waste time - it rotates a block of memory and then copies the block of memory to the screen. Most of the work is done by the rotate part, but be aware that if it is displayed on the screen then a large chunk of the routine that is  moving data into contended memory is being hampered by the contended memory problem.

The routine starts by changing the border colour (at the top of the video screen) and when finished changes the border again (bottom of the screen). On my pc the border colour change is aligned with the  bottom of the screen for both parts.

The routine running in contended memory,  loops and rotates 625 bytes.   (border BLUE - ends when the border turns RED)

The 2nd routine running in uncontended memory, loops and rotates 625+88=713 bytes E.G it loops 713 times (Border MAGENTA, ends on GREEN)

The timing of both routines is near enough exactly the same. Yet one has managed 625 loops and the other 713 loops.

The difference is very measuarable.

 


    org    #7fA0


amount        equ    625
high_amount    equ    625+88

low_s        equ    #7000
high_s        equ    #9000


start:
    LD    HL,#4000
    LD    (HL),0
    LD    DE,#4001
    LD    BC,192*32
    ldir
    ld    bc,24*32-1
    ld    (hl),7
    LDIR
    ld    sp,#ffff
part1
    ld    hl,low_s
    ld    bc,amount
    ld    a,1
    call    init
loopy    push    bc
    halt
    ld    a,1               
    out    (254),a   ;<<<< set the border BLUE
    ld    bc,amount
    ld    hl,low_s
    push    hl
    push    bc
loop    rlc    (hl)
    inc    hl
    dec    bc
    ld    a,b
    or    c
    jr    nz,loop
    pop    bc
    ld    de,#4000
    pop    hl
    ldir
    ld    a,2
    out    (254),a   ; Set the border RED
    pop    bc
    djnz    loopy
    jp    part2


init    ld    e,l
    ld    d,h
    inc    de
    ld    (hl),a
    ldir
    ret

    org    #8000
part2:
    ld    hl,high_s
    ld    bc,high_amount
    ld    a,254
    call    init
high_loopy:
    push    bc
    halt
    ld    a,3
    out    (254),a    ; set the border MAGENTA
    ld    bc,high_amount
    ld    hl,high_s
    push    hl
    push    bc
high_loop:
    rlc    (hl)
    inc    hl
    dec    bc
    ld    a,b
    or    c
    jr    nz,high_loop
    pop    bc
    ld    de,#4000
    pop    hl
    ldir
    ld    a,4
    out    (254),a    ; set the border GREEN
    pop    bc
    djnz    high_loopy
    jp    part1

    end    start

Contended memory the upper border is BLUE, when the routine finishes it turns RED

Uncontended memory the upper border is MAGENTA when the routine finishes the border turns GREEN

 

 

The 2nd file - sets the loop counter to be the same  (in contended and uncontended) (e.g. it loops 625 times in contended and loops 625 times in uncontended) , the amount of time saved is shown by the movement of the border change.  



 

CONTEN~1.tap

Contend_same amount.tap

Edited by Norman Sword
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.