Booting high quality memory initialize program

Share your advanced PureBasic knowledge/code with the community.
User avatar
oryaaaaa
Addict
Addict
Posts: 825
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Booting high quality memory initialize program

Post by oryaaaaa »

This tips is 1st line only. program thread have high quality memory.
main target : sound player, photo viewer and digital output software in lab.

example 1

Code: Select all

[This code]
your software code


example 2

Code: Select all

[NOP NOP XOR PXOR code]
[This code]
your software code
Please check and try this code.
have fun.

Code: Select all

; Booting high quality memory initialize program 
; Copyright (c) Hiroyuki Yokota [oryaaaaa]
Declare ReWriteMemory_mmx(*in_buf, in_pos.i)

Procedure FirstRewriteProcess()
  Protected *memory, *memory2
  *memory = AllocateMemory(52428800, #PB_Memory_NoClear) ; every 50MB
  *memory2 = AllocateMemory(52428800, #PB_Memory_NoClear) ; every 50MB
  FillMemory(*memory, 52428800, 0, #PB_Byte)
  FillMemory(*memory2, 52428800, 0, #PB_Byte)
  FillMemory(*memory, 52428800, $FF, #PB_Byte)
  FillMemory(*memory2, 52428800, $FF, #PB_Byte)
  ReWriteMemory_mmx(*memory, 52428800)
  ReWriteMemory_mmx(*memory2, 52428800)
  FillMemory(*memory, 52428800, $F0, #PB_Byte)
  FillMemory(*memory2, 52428800, $F0, #PB_Byte)
  ReWriteMemory_mmx(*memory, 52428800)
  ReWriteMemory_mmx(*memory2, 52428800)
  FillMemory(*memory, 52428800, 0, #PB_Byte)
  FillMemory(*memory2, 52428800, 0, #PB_Byte)
  ReWriteMemory_mmx(*memory, 52428800)
  ReWriteMemory_mmx(*memory2, 52428800)
  FreeMemory(*memory)
  FreeMemory(*memory2)
  Delay(4000) ; need
EndProcedure

FirstRewriteProcess()

; more sound quality up priority List, need Declare sentence
Declare.l AsioProc(input.b, channel.l, *buffer, length.l, *User)
Declare CopyMemory(*memory, *memory2, mem_size.i, *dummy)
Declare CounterInfomation()
Declare LoadingMusic(Plist.b, index.l)

Procedure ReWriteMemory_mmx(*in_buf, in_pos.i)
  Protected s.i
  
  If in_pos%8>0
    s = in_pos + (8 - in_pos%8)
  Else
    s = in_pos
  EndIf
  
  If s < 1
    Goto ReWriteMemory_mmx_end
  EndIf 
  
  CompilerSelect #PB_Compiler_Processor
    CompilerCase #PB_Processor_x86
      !PXOR mm5, mm5
      !PXOR mm3, mm3 
      !MOV Eax, [p.v_s]
      !MOV Ecx, [p.p_in_buf]
      !ReWrite_mmx:
      !PXOR mm5, mm5
      !movq mm5, [Ecx]
      !movntq [Ecx], mm5
      !PXOR mm3, mm3
      !movq mm3, mm5
      !movntq [Ecx], mm3
      !ADD  Ecx, 8
      !SUB  Eax, 8
      !JNZ ReWrite_mmx
      !emms
    CompilerCase #PB_Processor_x64
      !PXOR mm5, mm5
      !PXOR mm3, mm3
      !MOV Rax, [p.v_s]
      !MOV Rcx, [p.p_in_buf]
      !ReWrite_mmx:
      !PXOR mm5, mm5
      !movq mm5, [Rcx]
      !movntq [Rcx], mm5
      !PXOR mm3, mm3
      !movq mm3, mm5
      !movntq [Rcx], mm3
      !ADD  Rcx, 8
      !SUB  Rax, 8
      !JNZ ReWrite_mmx
      !emms
  CompilerEndSelect 
  
  ReWriteMemory_mmx_end:
EndProcedure
User avatar
oryaaaaa
Addict
Addict
Posts: 825
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Re: Booting high quality memory initialize program

Post by oryaaaaa »

Bug head use this technique.

Code: Select all

; Bug head startup high quality vision
; Copyright (c) Hiroyuki Yokota [oryaaaaa]
!NOP
!NOP
!Mov Eax, 16384
!First_process:
!NOP
!NOP
!Dec Eax
!JNZ First_process
!PXOR mm0, mm0
!PXOR mm1, mm1
!PXOR mm2, mm2
!PXOR mm3, mm3
!PXOR mm4, mm4
!PXOR mm5, mm5
!PXOR mm6, mm6
!PXOR mm7, mm7
!emms
!PXOR xmm0, xmm0
!PXOR xmm1, xmm1
!PXOR xmm2, xmm2
!PXOR xmm3, xmm3
!PXOR xmm4, xmm4
!PXOR xmm5, xmm5
!PXOR xmm6, xmm6
!PXOR xmm7, xmm7
!Mov Eax, 32768
!First_process_x2:
!NOP
!NOP
!Dec Eax
!JNZ First_process_x2

Declare ReWriteMemory_mmx(*in_buf, in_pos.i)

Procedure FirstRewriteProcess()
  Protected *memory
  *memory = AllocateMemory(52428800, #PB_Memory_NoClear) ; every 50MB
  FillMemory(*memory, 52428800, 0, #PB_Byte)  : Delay(128)
  FillMemory(*memory, 52428800, $FF, #PB_Byte) : Delay(128)
  ReWriteMemory_mmx(*memory, 52428800) : Delay(128)
  FillMemory(*memory, 52428800, $F0, #PB_Byte) : Delay(128)
  ReWriteMemory_mmx(*memory, 52428800) : Delay(128)
  FillMemory(*memory, 52428800, 0, #PB_Byte) : Delay(128)
  ReWriteMemory_mmx(*memory, 52428800) : Delay(128)
  FreeMemory(*memory)
  Delay(3584) ; need
EndProcedure

FirstRewriteProcess()

Procedure ReWriteMemory_mmx(*in_buf, in_pos.i)
  Protected s.i
  
  If in_pos%8>0
    s = in_pos + (8 - in_pos%8)
  Else
    s = in_pos
  EndIf
  
  If s < 1
    Goto ReWriteMemory_mmx_end
  EndIf 
  
  CompilerSelect #PB_Compiler_Processor
    CompilerCase #PB_Processor_x86
      !PXOR mm5, mm5
      !PXOR mm3, mm3 
      !MOV Eax, [p.v_s]
      !MOV Ecx, [p.p_in_buf]
      !ReWrite_mmx:
      !PXOR mm5, mm5
      !movq mm5, [Ecx]
      !movntq [Ecx], mm5
      !PXOR mm3, mm3
      !movq mm3, mm5
      !movntq [Ecx], mm3
      !ADD  Ecx, 8
      !SUB  Eax, 8
      !JNZ ReWrite_mmx
      !emms
    CompilerCase #PB_Processor_x64
      !PXOR mm5, mm5
      !PXOR mm3, mm3
      !MOV Rax, [p.v_s]
      !MOV Rcx, [p.p_in_buf]
      !ReWrite_mmx:
      !PXOR mm5, mm5
      !movq mm5, [Rcx]
      !movntq [Rcx], mm5
      !PXOR mm3, mm3
      !movq mm3, mm5
      !movntq [Rcx], mm3
      !ADD  Rcx, 8
      !SUB  Rax, 8
      !JNZ ReWrite_mmx
      !emms
  CompilerEndSelect 
  
  ReWriteMemory_mmx_end:
EndProcedure
;
; ------------------------------------------------------------
;
;   PureBasic - Sound example file
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

If InitSound() = 0
  MessageRequester("Error", "Can't open DirectX 7 or no sound card is available",  0)
  End
EndIf

UseFLACSoundDecoder()

SoundFileName$ = OpenFileRequester("Choose a sound file", "", "Wave or Flac files|*.wav;*.flac",0)
If SoundFileName$
  If LoadSound(0, SoundFileName$)
    PlaySound(0,#PB_Sound_Loop)
    MessageRequester("Sound", "Playing the sound (loop)..."+Chr(10)+"Click to quit..", 0)
  Else
    MessageRequester("Error", "Can't load the sound.", 0)
  EndIf
EndIf
End   
Post Reply