mirror of
				https://github.com/irmen/prog8.git
				synced 2025-10-31 00:16:08 +00:00 
			
		
		
		
	added cx16.getrambank() / getrombank() to retrieve the current ram and rom bank numbers.
This commit is contained in:
		| @@ -381,6 +381,20 @@ inline asmsub rambank(ubyte bank @A) { | |||||||
|     }} |     }} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | inline asmsub getrombank() -> ubyte @A { | ||||||
|  |     ; -- get the current rom bank | ||||||
|  |     %asm {{ | ||||||
|  |         lda  $01            ; rom bank register (v39+, used to be cx16.d1prb $9f60 in v38) | ||||||
|  |     }} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | inline asmsub getrambank() -> ubyte @A { | ||||||
|  |     ; -- get the current ram bank | ||||||
|  |     %asm {{ | ||||||
|  |         lda  $00            ; ram bank register (v39+, used to be cx16.d1pra $9f61 in v38) | ||||||
|  |     }} | ||||||
|  | } | ||||||
|  |  | ||||||
| asmsub numbanks() -> ubyte @A { | asmsub numbanks() -> ubyte @A { | ||||||
|     ; -- uses MEMTOP's cx16 extension to query the number of available RAM banks. (each is 8 Kb) |     ; -- uses MEMTOP's cx16 extension to query the number of available RAM banks. (each is 8 Kb) | ||||||
|     %asm {{ |     %asm {{ | ||||||
|   | |||||||
| @@ -1,43 +1,31 @@ | |||||||
| %import textio | %import textio | ||||||
| %zeropage basicsafe | %zeropage basicsafe | ||||||
|  | %option no_sysinit | ||||||
|  |  | ||||||
| main { | main { | ||||||
|  |  | ||||||
|     ubyte[64*3] palette |  | ||||||
|  |  | ||||||
|     sub start() { |     sub start() { | ||||||
|         ubyte i |         ubyte num_banks = cx16.numbanks() | ||||||
|         for i in 0 to len(palette)-1 { |         txt.print("number of ram banks ") | ||||||
|             palette[i] = 15 |         txt.print_ub(num_banks) | ||||||
|  |         txt.print(" = ") | ||||||
|  |         txt.print_uw($0008*num_banks) | ||||||
|  |         txt.print("kb\n") | ||||||
|  |         print_banks() | ||||||
|  |         cx16.rambank(55) | ||||||
|  |         cx16.rombank(3) | ||||||
|  |         print_banks() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|         for i in 0 to len(palette)-1 { |     sub print_banks() { | ||||||
|             txt.print_ubhex(palette[i], false) |         ubyte rambank = cx16.getrambank() | ||||||
|         } |         ubyte rombank = cx16.getrombank() | ||||||
|  |         cx16.rombank(0) ; enable kernal | ||||||
|  |         txt.print("ram bank ") | ||||||
|  |         txt.print_ub(rambank) | ||||||
|         txt.nl() |         txt.nl() | ||||||
|         make_ehb_palette() |         txt.print("rom bank ") | ||||||
|         for i in 0 to len(palette)-1 { |         txt.print_ub(rombank) | ||||||
|             txt.print_ubhex(palette[i], false) |  | ||||||
|         } |  | ||||||
|         txt.nl() |         txt.nl() | ||||||
|  |         cx16.rombank(rombank) | ||||||
|     } |  | ||||||
|  |  | ||||||
|     sub make_ehb_palette() { |  | ||||||
|         ; generate 32 additional Extra-Halfbrite colors in the cmap |  | ||||||
|         uword palletteptr = &palette |  | ||||||
|         uword ehbptr = palletteptr + 32*3 |  | ||||||
|         repeat 32 { |  | ||||||
|             @(ehbptr) = @(palletteptr)>>1 |  | ||||||
|             ehbptr++ |  | ||||||
|             palletteptr++ |  | ||||||
|             @(ehbptr) = @(palletteptr)>>1 |  | ||||||
|             ehbptr++ |  | ||||||
|             palletteptr++ |  | ||||||
|             @(ehbptr) = @(palletteptr)>>1 |  | ||||||
|             ehbptr++ |  | ||||||
|             palletteptr++ |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| } |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user