Created
August 14, 2021 05:00
-
-
Save S0urceror/63ffbd58b9e58c083c12fb9b071a24d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org 08000h | |
ld hl, 08000h ; this memory area | |
call Memory_GetSlot | |
call GET_SLTWRK_FOR_SLOT | |
; retrieve pointer from SLTWRK area | |
ld e,(hl) | |
inc hl | |
ld d,(hl) | |
; do something with it | |
; | |
; | |
ret | |
GET_SLTWRK_FOR_SLOT: | |
; formula: SLTWRK address = FD09H + 32*primary slot + 8*expansion slot + 2*page | |
ld b, a | |
and 00000011b; select primary slot | |
ld hl,0 | |
ld l,a | |
add hl, hl | |
add hl, hl | |
add hl, hl | |
add hl, hl | |
add hl, hl; multiply by 32 | |
ld a, b | |
and 00001100b; select extended slot | |
sla a; times 2 | |
ld de, 0 | |
ld e, a | |
add hl, de | |
ld de, SLTWRK | |
add hl, de | |
ld a, (hl) | |
ld e, a | |
inc hl | |
ld a, (hl) | |
ld d, a | |
ld hl, de | |
or a ; clear Cy | |
ret | |
; h = memory address high byte (bits 6-7: page) | |
; a <- slot ID formatted FxxxSSPP | |
; Modifies: f, bc, de | |
Memory_GetSlot: | |
call BIOS_RSLREG | |
bit 7,h | |
jr z,PrimaryShiftContinue | |
rrca | |
rrca | |
rrca | |
rrca | |
PrimaryShiftContinue: | |
bit 6,h | |
jr z,PrimaryShiftDone | |
rrca | |
rrca | |
PrimaryShiftDone: | |
and #0b00000011 | |
ld c,a | |
ld b,#0 | |
ex de,hl | |
ld hl,#BIOS_EXPTBL | |
add hl,bc | |
ld a,(hl) | |
and #0x80 | |
or c | |
ld c,a | |
inc hl ; move to SLTTBL | |
inc hl | |
inc hl | |
inc hl | |
ld a,(hl) | |
ex de,hl | |
bit 7,h | |
jr z,SecondaryShiftContinue | |
rrca | |
rrca | |
rrca | |
rrca | |
SecondaryShiftContinue: | |
bit 6,h | |
jr nz,SecondaryShiftDone | |
rlca | |
rlca | |
SecondaryShiftDone: | |
and #0b00001100 | |
or c | |
ld l, a | |
ret |
Memory_GetSlot can also be optimized greatly. For starters, it's written as a universal routine, but you are supplying a fixed input.
Thanks D15CODE, yes you can certainly optimize but the principle remains at every HTIMI I have to lookup my WRKAREA.
Yes, but if the overhead is small(er), what's the problem? Compared to the overhead of the interslotcall you probably have on the H.TIMI hook, this is nothing.
Allocating more memory in page 3 leads to all kinds of compatibility problems. It's too short-sighted.
Yes, we have to balance performance with memory. I also don’t like taking more page 3 then necessary. With MSX Dos 2/Nextor there is already a lot used there.
Sent by phone
…________________________________
From: D15C0DE ***@***.***>
Sent: Sunday, August 15, 2021 2:23:37 PM
To: S0urceror ***@***.***>
Cc: S0urceror ***@***.***>; Author ***@***.***>
Subject: Re: S0urceror/sltwrk.asm
@D15C0DE commented on this gist.
________________________________
Allocating more memory in page 3 leads to all kinds of compatibility problems. It's too short-sighted.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://gist.github.com/63ffbd58b9e58c083c12fb9b071a24d7#gistcomment-3861738>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABGC6KG25WCFKJVMLMN5UETT46WUTANCNFSM5CFEVTIQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is highly unoptimized. Instead of trying to find a non-standard approach, you could just optimize it like this: