;;Settings positions
CR1 = $d011; ;Graphic settings
VIC_bank_settings = $DD00 ; Vic position
Screen_RAM_settings =$D018 ;Screen RAM position relative to VIC

;;########## VIC_BANK ################
;;#	BITMAP | $4000 -$5F3F
;;#  Unused? |  $5F3F - $6000
;;#	SCREAN RAM (color) | $6000 -$63E7
;;#  Unused? | $63E8 - $7FFF
;;#
;;####################################

;;Memory positions
VIC_bank = $4000
VIC_bank_end = VIC_bank + $3FFF

Bitmap = VIC_bank
Bitmap_end = $5F3F

Screen_RAM = $2000 + VIC_bank
Screen_RAM_end = Screen_RAM + $03E7

Character_generator_ROM = $D000

;;Free upp memory
;;https://www.c64-wiki.com/wiki/Bank_Switching
;;
;;Sets grafic mode [Standard bitmap mode]
;;https://www.c64-wiki.com/wiki/Standard_Bitmap_Mode
LDA #%10111111 ; ECM = False
AND CR1
STA CR1

LDA #%00100000; BMM = True
ORA CR1
STA CR1

;;Set VIC bank to bank 1
;;https://www.c64-wiki.com/wiki/VIC_bank
LDA #%11111110 ;bit_0 = False
AND VIC_bank_settings
STA VIC_bank_settings

LDA #%00000010; bit_1 = True
ORA VIC_bank_settings
STA VIC_bank_settings

;;Set Scren-RAM to offset 8 ;https://www.c64-wiki.com/wiki/53272   (offset is 8k byte = 1024*8-ich)
LDA #%10001111 ; bit_6 =bit_5=bit_4 = Falsw
AND Screen_RAM_settings
STA Screen_RAM_settings

LDA #%10000000; bit_1 = True
ORA Screen_RAM_settings
STA Screen_RAM_settings


;;Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM
LDA #>VIC_bank
STA $FC
LDA #<VIC_bank
STA $FB

LDA #>$5f3f
STA $FE
LDA #<$5f3f
STA $FD

LDA #$0
jsr memset

;;Sets the screen color to black and white
LDA #>Screen_RAM
STA $FC
LDA #<Screen_RAM
STA $FB

LDA #>Screen_RAM_end
STA $FE
LDA #<Screen_RAM_end
STA $FD

LDA #%11110000
jsr memset

SEI ;Disable interups (not all)
;;Disable BASIC ROM mohahaha
LDA #%11111110
AND $0001
STA $0001
;https://www.c64-wiki.com/wiki/Bank_Switching
;Disable IO, CHAREN =0
LDA #%11111011
AND $0001
STA $0001