zaterdag 28 oktober 2023

C64: Border removal

// use the kickassembler to assemble this code
:BasicUpstart2(Main)	
.pc = * "Code Segment"
Main:
	sei
	lda #<Interrupt
	sta $0314
	lda #>Interrupt
	sta $0315
	lda #$f9
	sta $d012
	sta $dc0e
	lda #$01
	sta $d019
	sta $d01a
	lda $d011
	and #%01111111
	sta $d011
	cli
	rts
Interrupt:
	lda #$01
	sta $d019
	lda $d011
	and #$f7
	sta $d011
Loop:
	lda $d012
	bne Loop
	lda $d011
	and #$7f
	ora #$08
	sta $d011
	jmp $ea31

C64: Smoothscroller in an interrupt!

//use kickassembler to assemble
:BasicUpstart2(Main)	
.pc = * "Code Segment"
	
Main:
	sei
	lda $d011
	and #%01111111
	sta $d011	// clear top bit of raster register
	lda #$7f
	sta $d012	// raster register
	
	lda #<Interrupt
	sta $0314
	lda #>Interrupt
	sta $0315
	
	lda #$01	// current raster count = wanted position. We handle the interrupt.
	sta $d019	// interrupt status byte
	sta $d01a	// interrupt enable byte
	
	lda #$7f 
	sta $dc0d	// disable cia 1
	sta $dd0d   // disable cia 2
	
	ldx #39
!loop:
	lda #' '
	sta $400+$190-40, x	// regel erboven vullen met spaties
	sta $400+$190, x	// scrollregel zelf vullen met spaties
	sta $400+$190+40, x  	// regel eronder vullen met spaties
	lda #1
	sta $d800+$190,x	// kleuren zetten in de scrollregel
	dex
	bpl !loop-
	
	lda $d020
	sta old_colors
	lda $d021
	sta old_colors+1
	
	lda $dc0d	// acknowledge pending interrupts from CIA-1
	lda $dd0d	// acknowledge pending interrupts from CIA-2
	
	cli
	rts
	
	
Interrupt:
	ldx #3		// vertraging om de zwarte kleur niet midden in je scherm te krijgen
!loop:
	dex
	bne !loop-
	
	lda #0
	sta $d020
	sta $d021
	lda scrollposition
	sta $d016
	
!loop:
	lda $d012
	cmp #$8c	// wacht totdat het raster een aantal regels verder is.
	bne !loop-
	
	lda #$08	// scrolling weer uitzetten
	sta $d016
	
	ldx	#8	// vertraging om de zwarte kleur niet midden in je scherm te krijgen
!loop:
	dex
	bne !loop-
	
	lda old_colors
	sta $d020
	lda old_colors+1
	sta $d021
	
	dec scrollposition
	bpl no_scrollposition_reset
	
	lda #7		// de volgende scrollpositie wordt weer ver naar rechts
	sta scrollposition
	
	ldx #0
!loop:
	lda $591, x	// copy line to the left
	sta $590, x
	inx
	cpx #39
	bne !loop-	
	
	ldx scrolltext_needle	// scrolltext resetten?
	lda scrolltext, x
	cmp #0
	bne no_scrolltext_reset
	lda #0
	sta scrolltext_needle
	lda scrolltext
no_scrolltext_reset:
	sta $400+$190+39
	inc scrolltext_needle	
	
no_scrollposition_reset:
	lda #$01    	// current raster count = wanted position. We handle the interrupt.
	sta $d019	// interrupt status byte.  asl $d019 werkt ook, maar waarom weet ik niet.
	jmp $ea31


scrollposition:
	.byte 0
	
scrolltext:
	.text "jawel ouwe, een smoothscroller op de commodore 64 in een interrupt!                     "
	.byte 0

scrolltext_needle:
	.byte 0

old_colors:
	.byte 0,0

vrijdag 27 oktober 2023

C64: Border removal via basic

10 f=49152
20 read a
30 if a=255 then sys 49152:goto 170
40 poke f,a
50 f=f+1
60 goto 20
70 :
80 data 120,169,34,141,20,3,169,192
90 data 141,21,3,169,249,141,18,208
100 data 141,14,220,169,1,141,25,208
110 data 141,26,208,169,27,141,17,208
120 data 88,96,169,1,141,25,208
130 data 173,17,208,41,247,141
140 data 17,208,173,18,208,208,251,173
150 data 17,208,41,127,9,8,141,17
160 data 208,76,49,234,255
170 for x=832 to 832+63:pokex,255:next
180 poke 2040,13
190 v=53248:poke v+21,1:poke v+1,5
200 poke v+0,100:poke53280,0:poke53281,0
210 poke 646,rnd(1)*16:print "rene   ";
220 goto 210

By the way: the VICE commodore 64 emulator is very good!
You can insert lines in VICE by using alt-insert.
With alt-delete you copy the C64 screen in the clipboard.
Reset: sys64738
Cool effect:
0 print chr$(205.5+rnd(1));:goto

https://www.youtube.com/watch?v=caW7aiasrvs

Close a user connection to a database in Postgresql

select * from pg_catalog.pg_stat_activity;

select pg_terminate_backend(pid)
from pg_catalog.pg_stat_activity
where pid = [nr found in column pid from previous query]

zondag 15 oktober 2023

Create a Visual Studio C++ LIB file from a C file

Start the x64 Native Tools Command Prompt for VS 2022
cl.exe stb_image.c
lib.exe stb_image.obj

... and the stb_image.lib is generated...

donderdag 12 oktober 2023

Dependencies of a .dll

Do you want to see the load time dependencies of a random .dll?
The best free tool is: https://github.com/lucasg/Dependencies

Create a Visual Studio C++ .lib file from a .dll

 Start the x64 Native Tools Command Prompt for VS 2022:
> dumpbin.exe /EXPORTS SDL2.dll > SDL2.exports
> Copy only the names with the 'Alt'-key column selection in Notepad++. Paste the names list in a new file named SDL2.def and write EXPORTS as the first line.
> So the file contents of the SDL2.def is:
EXPORTS
SDL_AddEventWatch
SDL_AddHintCallback
SDL_AddTimer
...

> lib.exe /def:SDL2.def /machine:x64 /out:SDL2.lib

dinsdag 3 oktober 2023

Nexus E401 unable to authenticate problem

npm login --scope=@mycorp --registry=https://registry.mycorp.com

Check in the .npmrc in your user folder if the token is acurate. Remove the tokens if unsure.